【问题标题】:Why am I getting an error in my web.config file为什么我的 web.config 文件中出现错误
【发布时间】:2011-07-12 20:25:05
【问题描述】:

我在 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> 

拍摄于directly from here

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

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

另外,我在 Visual Studio 中看到了这个:

元素缓存有无效的子元素“profiles”,可能的预期列表:cache、outputcache、outputcacheSettings、sqlCacheDependency'

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

【问题讨论】:

  • 在您提供的链接中,部分位于 我想知道这是否会有所不同。

标签: asp.net-mvc caching web-config profiles


【解决方案1】:

在您的屏幕截图中,您在&lt;system.web&gt; 下而不是&lt;system.webServer&gt; 下有缓存,并且由于配置文件不是&lt;caching&gt;&lt;system.web&gt; 的有效元素,您将收到该错误。

【讨论】:

    【解决方案2】:

    您在代码示例中显示的内容在&lt;system.webServer&gt; 下,您在屏幕截图中显示的内容在&lt;system.web&gt; 下,它需要在 webServer 下才能获得配置文件选项,在系统下.web 就像您拥有它一样提供了您收到的错误所涉及的所有选项,根据您从哪里调用它,其行为会有所不同

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-09-22
      • 2014-05-23
      • 2019-07-16
      • 1970-01-01
      • 2014-11-30
      相关资源
      最近更新 更多