determining if a user is authenticated

Discussion in 'ASP .Net' started by Robert Rotstein, Nov 21, 2005.

  1. How does one determine from Global.Application_BeginRequest() -- where
    no Session information is available -- whether the invoking user has
    been authenticated?
     
    Robert Rotstein, Nov 21, 2005
    #1
    1. Advertising

  2. The application events occur in this sequence: BeginRequest,
    AuthenticateRequest, AuthorizeRequest. Therefore you can determine if the
    user was authenticated only starting at the AuthenticateRequest event
    handling, e.g.

    Sub Application_AuthenticateRequest(ByVal sender As Object, ByVal e As
    EventArgs)
    Dim app As HttpApplication = CType(sender, HttpApplication)
    If app.Context.User.Identity.IsAuthenticated Then
    'do something
    End If
    End Sub
    --
    HTH,
    Phillip Williams
    http://www.societopia.net
    http://www.webswapp.com


    "Robert Rotstein" wrote:

    > How does one determine from Global.Application_BeginRequest() -- where
    > no Session information is available -- whether the invoking user has
    > been authenticated?
    >
     
    =?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=, Nov 21, 2005
    #2
    1. Advertising

  3. You don't. There no access to Session from
    that event, as you have already found out.

    SessionState is not loaded until after the BeginRequest
    has fired and before the EndRequest has fired.

    Specifically, Session is accessible after AcquireRequestState has fired :

    http://msdn.microsoft.com/library/d...papplicationclassacquirerequeststatetopic.asp

    You might want to use any event which fires after AcquireRequestState
    has fired, like HttpApplication.PreRequestHandlerExecute :

    http://msdn.microsoft.com/library/d...papplicationclassacquirerequeststatetopic.asp

    You could also use the PreSendRequestContent event :
    http://msdn.microsoft.com/library/d...pplicationClassPreSendRequestContentTopic.asp



    Juan T. Llibre, ASP.NET MVP
    ASP.NET FAQ : http://asp.net.do/faq/
    ASPNETFAQ.COM : http://www.aspnetfaq.com/
    Foros de ASP.NET en EspaƱol : http://asp.net.do/foros/
    ======================================
    "Robert Rotstein" <> wrote in message
    news:fwcgf.1303$%%5.1302@trndny06...
    > How does one determine from Global.Application_BeginRequest() -- where no Session
    > information is available -- whether the invoking user has been authenticated?
     
    Juan T. Llibre, Nov 21, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kristofer Liljeblad

    Terminating a authenticated user

    Kristofer Liljeblad, Jun 30, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    474
    Kristofer Liljeblad
    Jun 30, 2003
  2. David Krussow
    Replies:
    2
    Views:
    649
    Richard
    Jan 17, 2005
  3. Olivier Verdin
    Replies:
    0
    Views:
    309
    Olivier Verdin
    Nov 5, 2004
  4. Benny Ng
    Replies:
    0
    Views:
    491
    Benny Ng
    Sep 19, 2005
  5. Abhijit
    Replies:
    0
    Views:
    162
    Abhijit
    Apr 12, 2004
Loading...

Share This Page