At what point after a WebSecurity.Login should WebSecurity.IsAuthenticated become true?
I have a utility function that checks WebSecurity.IsAuthenticated (amongst other things). If I call that function from the Login.cshtml page (from Starter Site templte) after WebSecurity.Login has succeeded then IsAuthenticated is false. However, during
processing of the next page the function finds IsAuthenticated as true.
WebSecurity.IsAuthenticated actually returns the value of HttpRequest.IsAuthenticated, which is true if the Forms Authentication cookie has been set and is current. It's not available until the user makes the next request after successfully logging in, which
is why you are seeing the behaviour that you describe.
AreJayEss
Member
3 Points
2 Posts
WebSecurity.Login: When does it populate the object?
Apr 18, 2011 01:53 PM|LINK
Hi,
At what point after a WebSecurity.Login should WebSecurity.IsAuthenticated become true?
I have a utility function that checks WebSecurity.IsAuthenticated (amongst other things). If I call that function from the Login.cshtml page (from Starter Site templte) after WebSecurity.Login has succeeded then IsAuthenticated is false. However, during processing of the next page the function finds IsAuthenticated as true.
Is that expected behaviour?
Mikesdotnett...
All-Star
155649 Points
19987 Posts
Moderator
MVP
Re: WebSecurity.Login: When does it populate the object?
Apr 18, 2011 04:22 PM|LINK
WebSecurity.IsAuthenticated actually returns the value of HttpRequest.IsAuthenticated, which is true if the Forms Authentication cookie has been set and is current. It's not available until the user makes the next request after successfully logging in, which is why you are seeing the behaviour that you describe.
Web Pages CMS | My Site | Twitter
AreJayEss
Member
3 Points
2 Posts
Re: WebSecurity.Login: When does it populate the object?
Apr 18, 2011 06:34 PM|LINK
Tht makes sense. Thankyou Mike.