[asp.net] FormsAuthentication.SignOut() does not log the user out

This Answer is technically identical to Khosro.Pakmanesh. I'm posting it to clarify how his answer differs from other answers on this thread, and in which use case it can be used.

In general to clear a user-session, doing

HttpContext.Session.Abandon();
FormsAuthentication.SignOut();

will effectively log out the user. However, if in the same Request you need to check Request.isAuthenticated (as may often happen in an Authorization Filter, for example), then you will find that

Request.isAuthenticated == true

even _after you did HttpContext.Session.Abandon() and FormsAuthentication.SignOut().

The only thing that worked was doing

AuthenticationManager.SignOut();
HttpContext.User = new GenericPrincipal(new GenericIdentity(string.Empty), null);

That effectively sets Request.isAuthenticated = false.