How to make sure that browser doesn't catch the aspx page so that when browser back button is pressed, the page reloads from server again?

Posted by Raja under ASP.NET category on | Views : 3197
Write following code in Page_Load event of the .aspx page and things will be taken care. Every time the user clicks back button from other page to come to this page, the page will be reloaded from server.

System.Web.UI.HtmlControls.HtmlGenericControl meta = new System.Web.UI.HtmlControls.HtmlGenericControl("meta");
meta.Attributes.Add("http-equiv", "Cache-Control");
meta.Attributes.Add("content", "no-cache");

System.Web.UI.HtmlControls.HtmlGenericControl meta1 = new System.Web.UI.HtmlControls.HtmlGenericControl("meta");
meta1.Attributes.Add("http-equiv", "Cache-Control");
meta1.Attributes.Add("content", "must-revalidate");


Comments or Responses

Login to post response