为什么我的 web.config 文件出现错误
我将以下部分添加到我的 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
另外,我在Visual Studio中看到了这一点:
元素缓存具有无效的子元素“配置文件”,可能的预期列表:缓存、输出缓存,outputcacheSettings,sqlCacheDependency'
对此配置进行了一些更改,因为我在网络上看到了很多具有此精确配置的示例?
I have the following section added to my 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>
which was taken directly from here
but I am getting an error in my web.config, saying:
Unrecognized configuration section system.web/caching/profiles
also, I see this in visual studio:
The element caching has invalid child element 'profiles', List of possible expected: cache, outputcache, outputcacheSettings, sqlCacheDependency'
did something about this configuration change as I see alot of examples on the web with this exact configuration?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在您的屏幕截图中,您的缓存位于
下,而不是
下,并且由于配置文件不是下的有效元素。 caching>
for
你会得到这个错误。In your screenshot you have the caching under
<system.web>
and not<system.webServer>
and since profiles is not a valid element under<caching>
for<system.web>
you will get that error.您在代码示例中显示的内容位于
下,您在屏幕截图中显示的内容位于
下,它需要位于 < Strong>webServer 让它获取配置文件选项,在 system.web 下,就像您拥有的那样,它提供了您收到的错误正在谈论的所有选项,其行为根据您从何处调用而有所不同What you show in code example is under
<system.webServer>
, what you show in your screenshot is under<system.web>
, it needs to be under webServer for it to get the profiles option, under system.web like you had it offers all those options that the error you received was talking about, behaves differently depending on where you call it from