Sunday, October 18, 2009

Avoid Navigating to previuos pages in Firefox ~ ASP.NET

I got a problem in where a user after logging out can navigate back to the pages that he visited previously without again logging in. The problem comes because the pages are not retrieved from the server but stored in the browser cache.This is how i avoided it.

I included this code in the page load of each page

Response.Buffer = True
Response.ExpiresAbsolute = DateTime.Now.AddDays(-1D)
Response.Expires = 0
Response.AppendHeader("Pragma", "no-cache")
Response.CacheControl = "no-cache"
If Not Page.User.Identity.IsAuthenticated Then
Response.Redirect("~/login.aspx", False)
End If

No comments: