【发布时间】:2011-08-27 09:09:41
【问题描述】:
我正在尝试根据这个问题的答案添加 custon 404 页面
ASP.NET MVC 404 handling and IIS7 <httpErrors>
通过添加
<httpErrors existingResponse="PassThrough" />
在我的 Web.Config 文件中的 <system.webServer> 标记下。
但我收到以下错误
Module: CustomErrorModule
Notification: SendResponse
Handler: System.Web.Mvc.MvcHandler
Error Code: 0x80070021
Config Error: This configuration section cannot be used at this path.
This happens when the section is locked at a parent level.
Locking is either by default (overrideModeDefault="Deny"),
or set explicitly by a location tag with overrideMode="Deny"
or the legacy allowOverride="false".
Config Source
153: <httpErrors existingResponse="PassThrough" />
154: </system.webServer>
我还尝试覆盖基于 http://learn.iis.net/page.aspx/145/how-to-use-locking-in-iis-70-configuration 的锁定(任务 2)
通过在 Web.config 中添加位置标记
如下
<configuration>
....
....
<location allowOverride="true">
<system.webServer>
<httpErrors existingResponse="PassThrough" />
</system.webServer>
</location>
</configuration>
但我遇到了同样的错误。
我应该如何在 Web.config 中配置 httpErrors 元素使其正常工作
我正在使用 IIS 7、VS 2010、ASP.NET MVC3
更新:
我能够摆脱锁定的错误
如果我修改 applicationHost.config 文件并更改
这个
<section name="httpErrors" overrideModeDefault="Deny" />
到
<section name="httpErrors" overrideModeDefault="Allow" />
但理想情况下我不想更改 applicationHost.config 文件并希望从 Web.config 文件中覆盖它
【问题讨论】:
-
您是否碰巧尝试了 exisitingResponse="Replace" 而不是“PassThrough”?
-
只为谷歌;德语错误消息为
Dieser Konfigurationsabschnitt kann in diesem Pfad nicht verwendet werden. Dies ist der Fall, wenn der Abschnitt auf übergeordneter Ebene gesperrt ist. Die Sperrung erfolgt standardmäßig (overrideModeDefault="Deny") oder wird explizit mit einem location-Tag mit overrideMode="Deny" oder der Legacyeinstellung allowOverride="false" festgelegt.。 -
是否可以将 configSource 与 httpErrors 一起使用?
标签: asp.net-mvc-3 iis-7 web-config