Re: Custom IIdentity class - how to set it?

Tech-Archive recommends: Speed Up your PC by fixing your registry

From: John Saunders (john.saunders)
Date: 02/20/04


Date: Fri, 20 Feb 2004 16:09:34 -0500


"Tim Mulholland" <TimMulholland@nospamaddress.com> wrote in message
news:uOeF4R$9DHA.3488@tk2msftngp13.phx.gbl...
> i've been looking into that...
> am i correct then in thinking that this event will be raised multiple
times
> per page request, and i'll handle it when they've been authenticated and
> fill in the User information then? So then the user information would be
> recreated (accessed from a db, or whatever) everytime a page loads?
> Is there a better way to do that?
> Or am i just totally missing something?

No. The event will only be raised once per page.

And, yes, it does have to be recreated every page load - so it would be a
good idea to avoid a database hit on each load. Many people do this by
setting the UserData field of the FormsAuthenticationTicket on their login
page, then reading the UserData during Application_AuthenticateRequest. The
idea would be to use it to hold information you'd otherwise have to go to
the database for, but which you don't mind having a bit out of date (it will
be from the time of login, if you never refresh it).

-- 
John Saunders
John.Saunders at SurfControl.com
> "John Saunders" <john.saunders at SurfControl.com> wrote in message
> news:ejYQ9I$9DHA.1052@TK2MSFTNGP12.phx.gbl...
> > "Tim Mulholland" <TimMulholland@nospamaddress.com> wrote in message
> > news:uBJBcX99DHA.1116@TK2MSFTNGP09.phx.gbl...
> > > I have created my own IIdentity class (actually inherited from
> > > GenericIdentity) to contain lots of extra useful information to be
> passed
> > > around with the user's basic information.
> > > The class compiles fine, no problems there.
> > >
> > > My problem is that i'm not sure where to actually set this to be part
of
> > the
> > > HttpContext. I know that the IIdentity stuff is part of a principal
> (which
> > > in my case will be a GenericPrinciple i suppose since i'm using forms
> > > authentication). So i figure it needs to be whenever the
> HttpContext.User
> > > object is set.
> > >
> > > What event is raised that i need to handle to be able to do this? I'm
> > going
> > > to be controlling all of the authentication using custom forms
> > > authentication.
> >
> > You need to do this sort of thing in the Application_AuthenticateRequest
> > event in global.asax.
> >
> > Be sure to check Request.IsAuthenticated, first, though!
> > -- 
> > John Saunders
> > John.Saunders at SurfControl.com
> >
> >
>
>


Relevant Pages

  • Webbrowser and basic authentication ...
    ... authentication dialogue box has been raised during page load? ... headers - e.g. set the Authorization header. ... any protected images won't load and then force the Basic Authentication ...
    (microsoft.public.vb.controls.internet)
  • Re: IsAuthenticated property on IIdentity interface
    ... > precise case, the constructor: ... GenericIdentity as your IIdentity implementation. ... Should I use the FormsIdentity class or is this class only ... adds construction-time specification of authentication status, ...
    (microsoft.public.dotnet.security)
  • Re: Session timeout & method="post"
    ... Forms Authentication Provider ... John Saunders johnwsaundersiii at hotmail> "John Saunders" wrote in message ...
    (microsoft.public.dotnet.framework.aspnet)
  • Custom IIdentity class - how to set it?
    ... I have created my own IIdentity class (actually inherited from ... GenericIdentity) to contain lots of extra useful information to be passed ... around with the user's basic information. ... to be controlling all of the authentication using custom forms ...
    (microsoft.public.dotnet.framework.aspnet)
  • RE: Howto know if we are in Forms or Windows authentication mode ?
    ... They actually represent the authentication type performed by the IIS web ... Load the setting from application's web.config ... Microsoft MSDN Online Support Lead ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.dotnet.framework.aspnet)