0

Force a page refresh on a ASP.NET MVC website

By Michael Alfaro on October 26, 2012
Share on Facebook1Tweet about this on Twitter3Share on LinkedIn0Google+0

So we had an issue where we wanted a page to always refresh and never be a cached version from the browser.  Jason found our solution here: http://forums.asp.net/t/1630103.aspx

Thanks to the ASP.Net forums once again!  Here’s the code we put in:


HttpContext.Response.Cache.SetExpires(DateTime.UtcNow.AddDays(-1));
HttpContext.Response.Cache.SetValidUntilExpires(false);
HttpContext.Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches);
HttpContext.Response.Cache.SetCacheability(HttpCacheability.NoCache);
HttpContext.Response.Cache.SetNoStore();