preview: In my web.config - I don't use forms authentication. I set forms cookie myself.
However - Sometimes I see code like this :
/*1*/ protected void Application_AuthenticateRequest(Object sender, EventArgs e)
/*2*/ {
/*3*/ if (HttpContext.Current.User != null)
/*4*/ {
/*5*/ if (HttpContext.Current.User.Identity.IsAuthenticated)
/*6*/ {
/*7*/ //...
/*8*/ HttpContext.Current.User = ....
/*9*/ //...
/*10*/ }
/*11*/ }
/*12*/ }
Looking at line #5
—
How can it ever be authenticated if line#8 is about to set authentication ?
I mean - line #8 is the one who set authentication for that specific request and when the request is finished , there is no "memory" for future requests. ( cookie expiration is merely - for how long to keep the persistent cookie).
Question
- In what scenarios would line
#5
returntrue
? - In what scenarios would line
#3
would benull
?
nb , this question assumes that begin_request
event is not setting anything , and the only stage where authentication is set is on Application_AuthenticateRequest
. — I don't use membership engine.
placeholder :
http://msdn.microsoft.com/en-us/library/aa289844(v=vs.71).aspx