0

我在 web.config 中添加了以下部分:

<system.webServer>
 <caching>
  <profiles>
   <add extension=".html" policy="CacheUntilChange" kernelCachePolicy="DontCache" location="Client" />
   <add extension=".htm" policy="CacheUntilChange" kernelCachePolicy="DontCache" location="Client" />
  <add extension=".gif" policy="CacheUntilChange" kernelCachePolicy="DontCache" location="Client" />
   <add extension=".js" policy="CacheUntilChange" kernelCachePolicy="DontCache" location="Client" />
   <add extension=".css" policy="CacheUntilChange" kernelCachePolicy="DontCache" location="Client" />
    <add extension=".jpg" policy="CacheUntilChange" kernelCachePolicy="DontCache" location="Client" />
    </profiles>
   </caching>
 </system.webServer> 

直接取自这里

但我的 web.config 中出现错误,说:

无法识别的配置部分 system.web/caching/profiles

另外,我在视觉工作室看到这个:在此处输入图像描述

元素缓存具有无效的子元素“配置文件”,可能的预期列表:缓存、输出缓存、输出缓存设置、sqlCacheDependency

当我在网上看到很多具有这种精确配置的示例时,这个配置是否发生了变化?

4

2 回答 2

3

在您的屏幕截图中,您有缓存<system.web>而不是缓存<system.webServer>,因为配置文件不是有效的元素<caching><system.web>您将收到该错误。

于 2011-07-12T12:22:35.787 回答
1

您在代码示例中显示的内容在下<system.webServer>,您在屏幕截图中显示的内容在下<system.web>,它需要在webServer下才能获得配置文件选项,在 system.web 下,就像您提供的所有选项一样,您收到的错误是谈论,行为不同,具体取决于您从哪里调用它

于 2011-07-12T12:23:58.110 回答