Asking again - which version of MR are you using?
I guess it's a wee bit old. Controller.Initialise() is public nowadays.

and this snippet on my pc:
        public override void Initialize()
        {
            string s = "";
            Context.Session["s"] = s;
            base.Initialize();
        }

is not throwing anything
using a rather new MR build.



On Tue, May 19, 2009 at 9:45 AM, Kcube <[email protected]> wrote:

>
>
> I have removed the User object and made it simple, please see
>
> public class ProfileController : BaseController
> {
>
> }
>
> =====================================================================
> [Layout("default")]
> [Filter(ExecuteEnum.BeforeAction, typeof(AuthenticationFilter))]
> public  class BaseController : SmartDispatcherController
> {
> protected override void Initialize()
> {
>        base.Initialize();
>        this.Context.Session["TestValue"] = "This is my test";
> }
>
> See the output :
>
>
> ?this.Context.Session
> null
> ?this.Context.Session.GetType()
> '((object)
> (((Castle.MonoRail.Framework.Adapters.DefaultRailsEngineContext)
> ((Castle.MonoRail.Framework.Controller)(this)).Context).Session))' is
> null
>
>
> Many Thanks,
> Kcube
>
> On May 19, 11:20 am, Ken Egozi <[email protected]> wrote:
> > there isn't any difference between getting to the server from a button, a
> > link, or a curl.exe call from console.
> >
> > now please make sure that the NullRef is on Context.Session, and not on
> the
> > cast from a non-existing value to (UserProfile)
> >
> >
> >
> >
> >
> > On Tue, May 19, 2009 at 9:17 AM, Kcube <[email protected]> wrote:
> >
> > > am really sorry .. i have tried moving base.Initialise() at the
> > > beginning . Still it is not working.
> >
> > > I am navigating the page using href .. should i use button and
> > > redirect the page to get the session.
> >
> > >  <li><a href="/UserAccount/Index.castle">Home</a></li>
> > >      <li><a href="/Profile/Home.castle">Profile</a></li>
> >
> > > Many Thanks,
> > > KCube
> >
> > > On May 18, 6:13 pm, Ken Egozi <[email protected]> wrote:
> > > > try to call base.Initialise() at the beginning of your override.
> >
> > > > On Mon, May 18, 2009 at 3:38 PM, Roelof Blom <[email protected]>
> > > wrote:
> > > > > MonoRail uses the ASP.NET session, so make sure <sessionState
> > > mode="Off">
> > > > > does not appear in your config
> >
> > > > > On Mon, May 18, 2009 at 2:21 PM, Kcube <[email protected]>
> wrote:
> >
> > > > >> am not using dotnet session, so should i modify the web.config..
> >
> > > > >> am using IRailsEngineContext.Session
> >
> > > > >> On May 18, 5:07 pm, Roelof Blom <[email protected]> wrote:
> > > > >> > Please make sure session state isn't disabled in web.config:
> > > > >>http://msdn.microsoft.com/en-us/library/h6bb9cz9(vs.71).aspx<http://msdn.microsoft.com/en-us/library/h6bb9cz9%28vs.71%29.aspx>
> <http://msdn.microsoft.com/en-us/library/h6bb9cz9%28vs.71%29.aspx>
> > > <http://msdn.microsoft.com/en-us/library/h6bb9cz9%28vs.71%29.aspx>
> >
> > > > >> > On Mon, May 18, 2009 at 2:00 PM, 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 -- Hide quoted text -
> >
> > > > >> > - Show quoted text -
> >
> > > > --
> > > > Ken Egozi.
> > >
> http://www.kenegozi.com/bloghttp://www.delver.comhttp://www.musicglue...quotedtext
>  -
> >
> > > > - Show quoted text -
> >
> > --
> > Ken Egozi.
> http://www.kenegozi.com/bloghttp://www.delver.comhttp://www.musicglue.comhttp://www.castleproject.orghttp://www.gotfriends.co.il-Hide
>  quoted text -
> >
> > - Show quoted text -
> >
>


-- 
Ken Egozi.
http://www.kenegozi.com/blog
http://www.delver.com
http://www.musicglue.com
http://www.castleproject.org
http://www.gotfriends.co.il

--~--~---------~--~----~------------~-------~--~----~
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