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

asp.net-mvc – asp.net MVC OutputCache属性的默认持续时间是多

发布时间:2020-12-16 09:55:52 所属栏目:asp.Net 来源:网络整理
导读:我们正在使用MVC outputcache属性,如下所示 [OutputCache(Location = System.Web.UI.OutputCacheLocation.Server,Duration = 60 * 60 * 12,VaryByParam = "staticDataTypes;customerSubscriptionId")] 这里什么是持续时间的默认值? 解决方法 Duration属性在
我们正在使用MVC outputcache属性,如下所示

[OutputCache(Location = System.Web.UI.OutputCacheLocation.Server,Duration = 60 * 60 * 12,VaryByParam = "staticDataTypes;customerSubscriptionId")]

这里什么是持续时间的默认值?

解决方法

Duration属性在System.Web.Configuration.OutputCacheProfile.cs中初始化,这是相关代码:

_propDuration = new ConfigurationProperty("duration",typeof(int),-1,ConfigurationPropertyOptions.None);

[ConfigurationProperty("duration",DefaultValue = -1)]
public int Duration {
    get { 
         return (int)base[_propDuration];
    } 
    set { 
        base[_propDuration] = value;
    } 
}

将其设置为默认值-1,这是一个无效值.持续时间属性的文档提到:’持续时间必须在使用配置文件的页面的配置文件或指令中定义.

因此,实际上没有(有效)默认值,您需要指定它.

(编辑:李大同)

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

    推荐文章
      热点阅读