public void AvoidCache()
{
HttpContext.Current.Response.Buffer = true;
HttpContext.Current.Response.Expires = 0;
HttpContext.Current.Response.ExpiresAbsolute = DateTime.Now.AddDays(-1);
HttpContext.Current.Response.AddHeader("pragma", "no-cache");
HttpContext.Current.Response.AddHeader("cache-control", "private");
HttpContext.Current.Response.CacheControl = "no-cache";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetAllowResponseInBrowserHistory(true);
}
/////////////// Or //////////////
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
StringBuilder javaScript = new StringBuilder();
javaScript.Append("\nscript language=JavaScript>\n");
javaScript.Append("window.history.forward(0);\n");
javaScript.Append(" Page.RegisterClientScriptBlock("HistoryScript", javaScript.ToString());
}
Saturday, February 7, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment