我已经为我的 ASPX 页面启用了页面缓存
<%@ OutputCache Duration="7200" VaryByParam="*" Location="Server" %>
但是,下次重新生成页面时,如果页面中发生错误,该页面也会被缓存,并且站点会在接下来的 7200 秒内继续显示包含错误的页面,或者直到某些依赖项刷新缓存.
目前我尝试将站点错误日志添加为文件依赖项,以便在记录错误时刷新页面。但是,这会导致页面被刷新,即使站点中的另一个页面出现错误也是如此。
问题是,如何在错误处理块中放入一段代码来取消缓存当前页面..
伪代码。
try
{
page load
}
catch (Exception ex)
{
// Add C# code to not cache the current page this time.
}