I just used a View Component and placed it in the layout.  this is not
exactly like you're trying to do (it uses AD at the backend) but you'll see
it has to access Session to properly work.  This is very early for me in my
Monorail experience  so please excuse it, but it has been working over a
year and with trunk upgrades.

[ViewComponentDetails("LoginInfoViewComponent")]
    public class LoginInfoViewComponent : ViewComponent
    {
        public override void Render()
        {
            if (Session["displayName"] == null)
            {
             //AD code here
                Session["displayName"] = userAttributes.DisplayName;
            }
            PropertyBag["loginuser"] = Session["displayName"].ToString();
            base.Render();
        }
    }

brail view:

Logged In As: ${loginuser} &nbsp;&nbsp;<img src="/Content/images/unlock.gif"
width="16" height="18" hspace="3" alt="Log out" /> <a
href="/Login/Index.Castle?LogOut=true">Log Out</a>

layout (place where needed):
<% component LoginInfoViewComponent %>

On Mon, May 18, 2009 at 7:00 AM, Kcube <[email protected]> wrote:

>
> i have tried with the below snippet.. but its not working
>
>  protected override void Initialize()
>        {
>            UserProfile user = (UserProfile)this.Context.Session
> ["GBL_CURRENT_USER"];
>            IUserProfile objUserProfile = (UserProfile)
> this.Context.Session["GBL_CURRENT_USER"];
>
>
>            PropertyBag["usernameforemsa"] = "test User";
>
>            base.Initialize();
>        }
>
> session object is null
>
> Thanks
> Kcube
>
> On May 18, 4:40 pm, Kcube <[email protected]> wrote:
> > thanks very much
> >
> > On May 18, 4:27 pm, Jimmy Shimizu <[email protected]> wrote:
> >
> >
> >
> > > Override the Initialize()-method in your controller, there you should
> > > have access to the http-context and the session, I think.
> >
> > > Kcube wrote:
> > > > How get session variable inside layout.
> >
> > > > I have tried these many methods, but couldn't find a good one
> >
> > > > 1) I want to show the logged-in user name in layout page. I have
> > > > tried
> > > > to access the session  variable inside the controller and set the
> > > > value to property bag and then access it in layout page $username.
> >
> > > > 2) I have inherited the controller from a base page and in the base
> > > > page constructor i tried to access session, but i am not able to
> > > > access the session inside the constructor.
> >
> > > > 3) I am able to access the session inside filter, but property bag is
> > > > not available inside filter.
> >
> > > > I am sure this is not proper mechanism to access the session variable
> > > > in side layout. Can anyone help me please?
> >
> > > > Sorry for asking basic question. Thanks in advance- Hide quoted text
> -
> >
> > > - Show quoted text -- Hide quoted text -
> >
> > - Show quoted text -
> >
>


-- 
Ryan Svihla
Systems Developer
Farm Bureau Bank

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to