加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

.net – MVC 5中的“CacheProfile”

发布时间:2020-12-16 04:05:04 所属栏目:asp.Net 来源:网络整理
导读:我是MVC的初学者,我有一个项目,从MVC2转换到最新版本的MVC. 我读了一些关于MVC 4的书,所以我开始理解主要的机制. 但是,在转换我的MVC 2解决方案时,我遇到了一个属性问题:OutputCache. 通过例如.我有多个这样的动作(属性可能会有所不同): [OutputCache(Cach
我是MVC的初学者,我有一个项目,从MVC2转换到最新版本的MVC.
我读了一些关于MVC 4的书,所以我开始理解主要的机制.

但是,在转换我的MVC 2解决方案时,我遇到了一个属性问题:OutputCache.

通过例如.我有多个这样的动作(属性可能会有所不同):

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

在Web.Config我有“缓存> outputCacheSettings> outputCacheProfiles>”:

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

并在输出中获取以下异常:

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.

据我所知,问题只出现在儿童行动中.

>在最新的MVC中是否有另一种方法可以获得缓存配置文件?
>有没有办法确定该动作是否为子动作才能修改该动作?

解决方法

解决了安装 MvcDonutCaching nuget并用[DonutOutputCache替换[OutputCache …

见more.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读