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);
}

posted on 2008-06-27 08:08  王丹小筑  阅读(739)  评论(2)    收藏  举报

导航