我在page_load事件中尝试了以下操作而没有运气。 (注意:页面语言是VB)
Response.Cache.SetCacheability(HttpCacheability.NoCache)
Response.Cache.SetExpires(DateTime.UtcNow.AddHours(-1))
Response.Cache.SetNoStore()
Response.Cache.SetMaxAge(New TimeSpan(0, 0, 30))
HttpContext.Current.Response.Cache.SetExpires(DateTime.UtcNow.AddDays(-1))
HttpContext.Current.Response.Cache.SetValidUntilExpires(False)
HttpContext.Current.Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches)
HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache)
HttpContext.Current.Response.Cache.SetNoStore()
答案 0 :(得分:0)
我添加了一些代码以从浏览器中删除缓存。我的页面加载事件添加
List<string> keys = new List<string>();
IDictionaryEnumerator enumerator = Cache.GetEnumerator();
while (enumerator.MoveNext())
keys.Add(enumerator.Key.ToString());
for (int i = 0; i < keys.Count; i++)
Cache.Remove(keys[i]);
在vb.net中
Dim keys As List(Of String) = New List(Of String)
Dim enumerator As IDictionaryEnumerator = Cache.GetEnumerator()
While enumerator.MoveNext()
keys.Add(enumerator.Key.ToString())
End While
For i = 0 To keys.Count - 1
Cache.Remove(keys(i))
Next i