2013-01-02 32 views
2

我只是新的ASP .NET,我想知道如何在保存并重定向到其他页面后清除所有数据条目?如何在完成保存数据后清除缓存?

我曾经尝试这样做我的HTML页面上,

<meta http-equiv="Pragma" content="no-cache"> 
<meta http-equiv="Expires" content="-1"> 

而且这对我的代码页的背后,

protected void Page_Load(object sender, System.EventArgs e) 
    { 
     if(!Page.IsPostBack) 
     { 
      Response.Cache.SetCacheability(HttpCacheability.Server); 
      Response.Expires = -1; 
      Response.AddHeader("Pragma", "No-Cache"); 
      Response.CacheControl = "no-cache"; 
     } 
    } 

但仍然每当我回到我的编码数据/页出现。

请帮助。非常感谢。谢谢。 :d

回答

1

它应该是:

Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1)); 
Response.Cache.SetCacheability(HttpCacheability.NoCache); 
Response.Cache.SetNoStore(); 
+0

我从其他页面去,但我点击'返回'后仍填充页面。我进入第2页后,我想要page1,然后再点击页面1将转到其原始视图。无论如何Thx帮助。 – pampi

0

如果你不希望浏览器保持填充表单域,您可以autocomplete设置HTML属性off

<input type="text" name="myfield" autocomplete="off" /> 
+0

我从其他页面转到页面,但点击'返回'后仍然填充页面。我进入第2页后,我想要page1,然后再点击页面1将转到其原始视图。无论如何Thx帮助。 – pampi