I have an ASP.NET project that I have created in Visual Studio 2010. So to begin the project, I got the generic "MY ASP.NET APPLICATION" page. I have since removed all that generic content and am building the application based off the needs of the user.
On my default.aspx page, I have a datagrid
wrapped in an UpdatePanel
. When a user selects a row from the datagrid
, I navigate to a new page. Everything is working fine but if the user was to click the back button in the browser, it acts as if it is loading the page from an old cached version because it shows the generic "MY ASP.NET APPLICATION" page again.
I have researched this for awhile and everything says that if you tell the Response
not to use the cache, it forces the Page_Load
to hit if the user clicks the back button. However, doing this is not working for me. If I were to click the refresh button, or type F5, then my page is reloaded successfully. I am using IE9 and here is what I have tried in the Page_Load
of my master page:
Response.Cache.SetExpires(DateTime.Now.AddDays(-1));
Response.Cache.SetValidUntilExpires(false);
Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches);
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetNoStore();
Response.Expires = -1441;
Response.ExpiresAbsolute = DateTime.Now.AddDays(-1);
Response.AppendHeader("pragma", "no-cache");
Response.CacheControl = "No-cache";
Response.AddHeader("cache-control", "no-store, no-cache, must-revalidate");
Also, I tried inserting this in master page's script:
<meta http-equiv="Expires" content="0"/>
<meta http-equiv="Cache-Control" content="no-cache"/>
<meta http-equiv="Pragma" content="no-cache"/>