且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用C#清除IE的缓存和Cookie

更新时间:2023-09-01 08:52:16

删除所有 Cache和Cookies 此处: http://support.microsoft.com/kb/326201 [
See here: http://support.microsoft.com/kb/326201[^]
This clears the cache and the cookies.


^ ]可能实际上会为您提供帮助.
This[^] might actually help you out.


// Clear cache
               Response.Cache.SetCacheability(HttpCacheability.NoCache);
               Response.Cache.SetExpires(DateTime.Now.AddSeconds(-1));
               Response.Cache.SetNoStore();

               //Clear cookies
               string[] cookies = Request.Cookies.AllKeys;
               foreach (string cookie in cookies)
               {
                   Response.Cookies[cookie].Expires = DateTime.Now.AddDays(-1);
               }