在 ASP.NET MVC4 应用程序中,我定义了一个自定义输出缓存提供程序。
我的配置是这样的:
<system.web>
<caching>
<outputCache defaultProvider="DiskOutputCache" enableOutputCache="true" >
<providers>
<add name="DiskOutputCache" type="ProExam.DMC.MvcUtil.DiskOutputCache, ProExam.DMC.MvcUtil, Version=1.0.0.0, Culture=neutral"/>
</providers>
</outputCache>
<outputCacheSettings>
<outputCacheProfiles>
<add name="forever" duration="2147483647" varyByParam="id" />
</outputCacheProfiles>
</outputCacheSettings>
</caching>
我有这样的操作:
[OutputCache(CacheProfile = "forever")]
public ActionResult View(UrlParamString id)
{
...
}
当我在 Debug模式下运行时,只会调用自定义输出缓存提供程序的 get 方法。永远不要设置或添加。任何帮助将不胜感激...
最佳答案
尝试缩短持续时间。您定义了几乎无限的缓存持续时间,这意味着当应用程序运行时,它不会再次尝试存储您的缓存项。
持续时间以秒为单位设置...尝试 duration="10"
或其他东西,看看会发生什么。
除此之外,您还可以尝试在缓存配置文件中定义 enabled="true"location="Server"
。
关于c# - 自定义 OutputCache 提供程序不工作(调用 get 但未设置或添加),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22231105/