将 401 自定义错误添加到 system.webServer.httpErrors 会给出“无法在 Web 服务器上启动调试”错误

发布于 2024-12-17 18:56:14 字数 628 浏览 5 评论 0原文

我从一个空白的 MVC 3 Web 应用程序开始。我在本地 IIS 中为 localhost:80 创建了一个新网站,并将新的 MVC 3 项目配置为使用该 Web 服务器而不是 VS 开发 Web 服务器。此时我可以正常运行和调试项目了。但如果我将其添加到 web.config 中,则会收到“无法在 Web 服务器上开始调试”错误。我可以选择启动而不调试,它工作正常。这是怎么回事?

<system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <modules runAllManagedModulesForAllRequests="true" />
    <httpErrors errorMode="Custom" existingResponse="Replace">
        <remove statusCode="401"/>
        <error statusCode="401" responseMode="ExecuteURL" path="/Error401" />
    </httpErrors>
</system.webServer>

I started with a blank MVC 3 web application. I created a new website in my local IIS for localhost:80 and configured my new MVC 3 project to use that web server instead of the VS development web server. At this point I can run and debug the project as normal. But if I add this to my web.config, I get an "Unable to start debugging on the web server" error. I can select Start without debugging and it works fine. What's the deal?

<system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <modules runAllManagedModulesForAllRequests="true" />
    <httpErrors errorMode="Custom" existingResponse="Replace">
        <remove statusCode="401"/>
        <error statusCode="401" responseMode="ExecuteURL" path="/Error401" />
    </httpErrors>
</system.webServer>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

原来是傀儡 2024-12-24 18:56:14

httpErrors 是仅由 IIS7 使用的新元素。这看起来有点奇怪,但是尝试在 system.web 部分 下的 Web 配置中添加以下内容:

<customErrors mode="RemoteOnly"  defaultRedirect="~/error">
    <error statusCode="401" redirect="~/Error401" />
</customErrors>

httpErrors are the new element which is only used by IIS7. This seems a little weird, however try adding the following in web config under system.web section:

<customErrors mode="RemoteOnly"  defaultRedirect="~/error">
    <error statusCode="401" redirect="~/Error401" />
</customErrors>
战皆罪 2024-12-24 18:56:14

我希望我能在这里给予更多的希望,但经过广泛的互联网研究,似乎没有解决方案。每当启用此配置节点时,即使调试之外没有明显错误,调试也不会启动。

我之前注意到证书问题可能会导致出现类似的错误。显然,调试器没有看到它期望的东西,因此失败了。

我的解决方案是仅在我们的测试环境及以上环境中启用此指令,同时在开发中禁用它。

I wish I could give some more hope here, but after extensive internet research, it seems that there is no resolution. Whenever this config node is enabled, debugging will not start, even if there are no obvious errors outside of debugging.

I have previously noticed that issues with the certificate can cause a similar error to occur. Apparently the debugger is not seeing something it expects and is failing as a result.

My solution will be to only enable this directive for our testing environment and above while leaving it disabled for development.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文