相关疑难解决方法(0)

使用缓存配置文件缓存ChildActions不起作用?

我正在尝试使用缓存配置文件缓存我的mvc应用程序中的子操作,但我得到一个例外:持续时间必须是正数.

我的web.config看起来像这样:

<caching>
      <outputCache enableOutputCache="true" />
      <outputCacheSettings>
        <outputCacheProfiles>
          <add name="TopCategories" duration="3600" enabled="true" varyByParam="none" />
        </outputCacheProfiles>
      </outputCacheSettings>
</caching>
Run Code Online (Sandbox Code Playgroud)

而我的孩子的动作是这样的:

[ChildActionOnly]
[OutputCache(CacheProfile = "TopCategories")]
//[OutputCache(Duration = 60)]
public PartialViewResult TopCategories()
{
    //...
    return PartialView();
}
Run Code Online (Sandbox Code Playgroud)

我只是打电话给一个视图 @Html.RenderAction("TopCategories", "Category")

但是我收到一个错误:Exception Details:System.InvalidOperationException:Duration必须是一个正数.

如果我不使用缓存配置文件,它的工作原理.知道问题是什么?

asp.net-mvc caching

17
推荐指数
2
解决办法
1万
查看次数

标签 统计

asp.net-mvc ×1

caching ×1