如何以编程清除缓存? [英] How can I programmatically clear cache?

查看:147
本文介绍了如何以编程清除缓存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序( ASP.NET + C#)我需要用户输入之前清除缓存aspx页面。

In my application (ASP.NET + c#) I need to clear the cache before a user enters an aspx page.

没有任何人有任何想法我如何以编程方式清除缓存一个aspx页面上,还是在后面的code(C#)?

Does anybody have any idea how I can programmatically clear the cache on an aspx page, or in the code behind (c#)?

推荐答案

写在下面的页面加载事件code:

Write following code in the page load event:

protected void Page_Load(object sender, EventArgs e)
{
    Response.Cache.SetCacheability(HttpCacheability.NoCache);
    Response.Cache.SetExpires(DateTime.Now);
    Response.Cache.SetNoServerCaching();
    Response.Cache.SetNoStore();
}

这篇关于如何以编程清除缓存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆