IIS7和客户端缓存与ASP.Net MVC
问题描述:
是否有可能声明性地设置clientCache
在IIS7中使用web.config的操作?IIS7和客户端缓存与ASP.Net MVC
我们需要为我们的Home/Index
操作设置1天的到期值。截至目前,我们正在使用filter属性来完成此操作。是否有可能以同样的方式完成声明?
我们可以通过web.config中的location
和system.webServer
部分对静态内容执行此操作,但不能执行操作方法。
<location path="Content">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
<system.webServer>
<staticContent>
<clientCache httpExpires="Sat, 28 Nov 2009 09:00:00 GMT" cacheControlMode="UseExpires" />
</staticContent>
</system.webServer>
</location>
答
我不认为在web.config中这样做是可以的 - 我们创建一个基础控制器并将其放在那里。这样我们就不必用属性来修饰所有的动作。