ASP.NET应用程序托管在IIS7被忽略的自定义错误,并回落到IIS错误 [英] ASP.NET Application hosted on IIS7 that is ignoring custom errors and falls back to IIS errors

查看:109
本文介绍了ASP.NET应用程序托管在IIS7被忽略的自定义错误,并回落到IIS错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个C#Web窗体ASP.NET使用路由为在我的web.config的system.web节中定义的一些原因,自定义错误的URL 4.0的Web应用程序被完全忽略,它会回落的IIS错误。

I have a C# web forms ASP.NET 4.0 web application that uses Routing for URLs for some reason custom errors defined in the system.web section of my web.config is entirely ignored and it will fall back the IIS errors.

这被完全忽略

  <system.web>
    <customErrors mode="On">
      <error statusCode="500" redirect="~/Error" />
      <error statusCode="404" redirect="~/404" />
      <error statusCode="403" redirect="~/Error" />
    </customErrors>
  </system.web>

这部分接管

  <system.webServer>
    <httpErrors>
      <!--<clear />-->
      <remove statusCode="500" subStatusCode="-1" />
      <remove statusCode="404" subStatusCode="-1" />
      <error statusCode="404" subStatusCode="-1" path="/App1/404" responseMode="Redirect" />
      <error statusCode="500" prefixLanguageFilePath="" path="/App1/Error" responseMode="Redirect" />
    </httpErrors>
  </system.webServer>

这将是一个小麻烦,除了通过它回落到IIS本地,而不是我的应用程序使其完全规避ELMAH正确登录我的404例外的事实。

This would be a minor inconvenience except that by the fact it falls back to IIS native instead of my application it completely circumvents Elmah logging my 404 exceptions correctly.

编辑:只是为了避免此类任何建议,我只加了httpErrors配置后的customErrors停止工作,所以我将有什么

Just to avoid any suggestions of such I only added the httpErrors configuration after customErrors stopped working so I would have anything.

推荐答案

要禁用,你必须设置IIS错误讯息

To disable the IIS error messages you have to set

  Response.TrySkipIisCustomErrors = true;

在您的错误页面。在这之后,你的错误消息应该显示没有问题。

in your error page. After that, your Error messages should show without problem.

这篇关于ASP.NET应用程序托管在IIS7被忽略的自定义错误,并回落到IIS错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆