ASP.NET(C#)中使IE缓存失效的代码
在ASP.NET中,要使页面每次访问都必须从服务器端重新加载,而不是从IE缓存中直接读取上次的暂存页,只需在Page_Load事件中添加如下代码 :
protected void Page_Load(object sender, EventArgs e)
{
Response.Buffer = true;
Response.ExpiresAbsolute = DateTime.Now.AddMinutes(-1);
Response.Expires = 0;
Response.CacheControl = "no-cache";
}


//简便的写法:
private void Page_Load(object sender, System.EventArgs e)
{
Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache);
}














本贴子以“现状”提供且没有任何担保,同时也没有授予任何权利
This posting is provided "AS IS" with no warranties, and confers no rights.
This posting is provided "AS IS" with no warranties, and confers no rights.