" CacheProfile"在MVC 5 [英] "CacheProfile" in MVC 5

查看:338
本文介绍了" CacheProfile"在MVC 5的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是初学者MVC和我有一个项目从MVC2转变为MVC的最新版本。 我读了读MVC 4一些书,所以我开始明白的主要机制。

I am beginner in MVC and I have a project to transform from MVC2 to the latest version of MVC. I read read some books on MVC 4, so I started to understand the main mechanisms.

然而,当我转换MVC 2的解决方案,我有一个问题,一个属性:的OutputCache

However, when transforming my MVC 2 solution, I have a problem with an attribute: OutputCache.

通过如。我有多个操作是这样的(属性可能会有所不同):

By eg. I have multiple Actions like this (the attributes may vary):

[OutputCache(CacheProfile = "ProductImage")]
public ActionResult GetImage(Guid elementId, int imgtype)

在web.config我已经在缓存> outputCacheSettings> outputCacheProfiles>

in the Web.Config i have in the "caching>outputCacheSettings>outputCacheProfiles>":

<add name="ProductImage" duration="5" varyByParam="elementId,imgtype" />

和输出获得以下异常:

OutputCacheAttribute儿童的行为只支持期限,   VaryByCustom是,和的VaryByParam值。请不要设置CacheProfile,   位置,NoStore,的SqlDependency,VaryByContentEncoding,或   VaryByHeader重视对儿童的行为。

OutputCacheAttribute for child actions only supports Duration, VaryByCustom, and VaryByParam values. Please do not set CacheProfile, Location, NoStore, SqlDependency, VaryByContentEncoding, or VaryByHeader values for child actions.

据我了解,只出现与孩子的行为问题。

As I understood, the problem appears only with the child actions.

  • 有另一种方式来在最新的MVC?
  • 系统缓存配置文件
  • 有没有一种方法,以确定是否该动作是孩子之一,以修改只是行动?
  • Is there another way to have a cache profile in the latest MVC?
  • Is there a way to identify if the action is a child one in order to modify just that action?

推荐答案

解决安装 MvcDonutCaching 的NuGet和更换 [的OutputCache [DonutOutputCache ...

Resolved installing MvcDonutCaching nuget and replacing [OutputCache with [DonutOutputCache...

请参阅更多约。

这篇关于&QUOT; CacheProfile&QUOT;在MVC 5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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