asp.net – MVC4在配置文件中查看缓存持续时间?
发布时间:2020-12-16 04:17:31 所属栏目:asp.Net 来源:网络整理
导读:是否有一个在MVC4 .net页面的web.config中设置缓存的持续时间?我有 : [OutputCache(Duration = Convert.ToInt32(ConfigurationManager.AppSettings["cache.eventPage"]),VaryByParam = "Id")]public ActionResult.... 哪个不会编译,因为 An attribute argu
是否有一个在MVC4 .net页面的web.config中设置缓存的持续时间?我有 :
[OutputCache(Duration = Convert.ToInt32(ConfigurationManager.AppSettings["cache.eventPage"]),VaryByParam = "Id")] public ActionResult.... 哪个不会编译,因为
我们有非常灵活的流量,并且希望能够在推出新版本的情况下非常快速地更改此值.这可能吗? 解决方法
你可以用
OutputCache profiles;在web.config中定义一个部分
<system.web> <caching> <outputCacheSettings> <outputCacheProfiles> <add name="CacheProfile1" duration="10" /> <!--10 seconds --> <add name="CacheProfile2" duration="3600" /> <!--one hour--> <add name="CacheProfileNone" duration="0" /> <!--disabled--> </outputCacheProfiles> </outputCacheSettings> </caching> </system.web> 通过您已经完成的属性在控制器操作方法上使用它.只需使用CacheProfile属性即可. [OutputCache(CacheProfile = "CacheProfile1",VaryByParam = "Id")] 您可以为每个缓存方案创建不同的配置文件. More info on caching at MSDN (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net-mvc-5 – 如何使用不同参数类型的相同路由?
- asp.net – IIS在编译的.net站点中查找.cs文件
- asp.net-mvc-4 – autofac – 依赖注入IHttpModule
- 如何将ASP.NET下拉列表DataTextField属性绑定到嵌套属性
- asp.net – 在离开Gridview页面后维护GridView当前页面索引
- asp.net – 使用外部connectionStrings.config文件进行WebP
- 在ASP.Net网站项目中混合VB.Net和C#代码?
- asp.net-mvc – 路由测试ASP.NET MVC4
- ASP.NET Core和JQuery不显眼的AJAX无法正常工作
- asp.net – 如何根据用户的角色创建具有不同显示的视图?
推荐文章
站长推荐
- asp.net-core – 如何使用Identity Server 4使用
- 单元测试 – 单元测试项目不能参考MVC项目
- asp.net-mvc – 如何降级Visual Studio 2012中的
- asp.net-mvc-4 – 使用RabbitMQ从ASP.net MVC 4消
- asp.net-mvc-4 – VS2012 RTM缺少.net 4.5和mvc项
- 为ASP.NET/ASP.NET MVC配置IIS(Windows 7)3
- asp-classic – 使用FileSystemObject的文件权限
- ASP.NET 3.5会话ID的大小是多少?
- asp-classic – 在经典ASP中检测字典对象
- ASP.NET Core中的依赖注入(4): 构造函数的选择
热点阅读