Do you have any other instances of IE open before, during, or after logging out? If not, you may find that the cookie still exists in the IE common cookie element.
Do you have an expiration date on your web pages? If not, the page may still be in the browser cache, and forms-based authentication on the server will not be called.
If you close your browser and try to access the protected resource again and must log in, then it is configured correctly .... The session cookie is not used as part of the forms authentication process, so you do not need to worry about it - FormsAuthentication.SignOut ( ) is the right way to do this.
In your Global.asax.cs application, add the following event handler — if you don't already have one — and set a breakpoint on it. If you hit a breakpoint for subsequent requests after you have called LogOff, you can crack the cookie and look at it. I suppose you will not hit this breakpoint because requests are served from the cache.
protected void Application_BeginRequest(object sender, EventArgs e) {}
To crack a cookie:
HttpRequest currentRequest = HttpContext.Current.Request;
It's also worth trying this in Firefox or Chrome, as they seem to be better off getting rid of the cookie.
To disable caching, you can put the following on one of the pages:
private static void SetImmediateExpiryOnResponse(HttpResponse response) { response.Cache.SetAllowResponseInBrowserHistory(false); response.Cache.SetCacheability(HttpCacheability.NoCache); response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1)); response.Cache.SetNoStore(); response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches); response.Expires = -1; response.ExpiresAbsolute = DateTime.Now.AddDays(-1); response.CacheControl = "no-cache"; }
source share