Page.User.Identity.IsAuthenticated gets its value from Page.User (obviously), which, unfortunately, is read-only and is not updated when FormsAuthentication.SignOut() called.
Fortunately, Page.User retrieves the value from Context.User , which can be changed:
// HttpContext.Current.User.Identity.IsAuthenticated == true; FormsAuthentication.SignOut(); HttpContext.Current.User = new GenericPrincipal(new GenericIdentity(string.Empty), null); // now HttpContext.Current.User.Identity.IsAuthenticated == false // and Page.User.Identity.IsAuthenticated == false
This is useful when you log out of the current user and want to respond to the actual page without the need for redirection. You can check IsAuthenticated where necessary in a single page request.
Mart Apr 10 '13 at 14:21 2013-04-10 14:21
source share