Re: session manager vs Form authentication in the Global.asax.cs f

From: Jasmine (Jasmine_at_discussions.microsoft.com)
Date: 06/09/05


Date: Thu, 9 Jun 2005 08:03:04 -0700

Hi Dominick,

Thanks for your answer.

I try to add "Session.add("myprincipal",principal) under Global.asax.cs ---
Application_PreRequestHandlerExecute, but this event will be called everytime
I try to request pages from web server, the Session only need to be added
once, how could I implement this?

Thanks, Jasmine

"Dominick Baier [DevelopMentor]" wrote:

> Hello Jasmine,
>
> do it later in the pipeline - when session state is available (e.g. PreRequestHandlerExecute)
>
> In AuthenticateRequest you store your principal to Context.User - pick this
> up in the later event and add it to the session.
>
> ---------------------------------------
> Dominick Baier - DevelopMentor
> http://www.leastprivilege.com
>
> > I am converting the asp.net application from window authentication to
> > form authentication.
> >
> > originally, the application create identity , principal , add session
> > under Session_Start event for window authentication, like:
> >
> > WindowIdentity wi=httpContext.current.user.Identity; GenericPrincipal
> > pp= new GenraicPrincipal(wi,roles); Session.Add("myPrincipal", pp);
> >
> > After I convert the app to form authentioncation. the identity and
> > principal code has been moved from Session_Start to
> > Application_AuthenticateRequest:like
> >
> > FormsIdentity fi = new FormsIdentity(authTicket);
> > GenericPrincipal pp= new GenraicPrincipal(Fi,roles);
> > My question is : How could I implement the "Session.Add("myPrincipal",
> > pp);"?
> >
> > the Session_start event start before the
> > Application_AuthenticateRequest , thus I won't know the FomsIdentity
> > (httpContext.Current.User.Identity) until I called
> > Application_AuthenticateRequest , thus, I have to generate the
> > principal object in the Application_AuthenticateRequest event, but
> > "Session.add() " cann't be called in Application_AuthenticateRequest
> > event, I got error("Session state is not availble in this context).
> >
> > Do you have any idea how to implement the "Session.Add("myPrincipal",
> > pp);" for form authentication?
> >
> > Thanks,
> >
>
>
>
>



Relevant Pages

  • Strange Session Restart
    ... I am using form authentication and InProc cookieless session. ... string strAccountName = Server.HtmlEncode; ... string strPassword = Server.HtmlEncode; ...
    (microsoft.public.dotnet.languages.csharp)
  • Strange Session Restart
    ... I am using form authentication and InProc cookieless session. ... string strAccountName = Server.HtmlEncode; ... string strPassword = Server.HtmlEncode; ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: problem with expired session
    ... But I am using form authentication! ... Is there any way to check if the session ... > Typically to avoid the session timeout issue and other session issues you ... >> I have some data driven pages with a datagrid set to allow paging. ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • RE: Form Validation/SessionID changes
    ... these behavious won't occur with a Form authentication. ... you please post the code for the login procedure? ... change the Session object's property any where, for example, mode or ... Luke ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • How to maintain ViewState in web-farm environment?
    ... across postback / request in a web farm environment. ... web server in the web farm, ... However, in mobile ASP.NET, view state is stored in session object ...
    (microsoft.public.dotnet.framework.aspnet.mobile)