ASP.NET自定义错误页面返回500

时间:2015-08-17 11:14:12

标签: asp.net visual-studio iis

当我像这样配置Web.config文件时:

<configuration>
<system.web>
  <compilation debug="true" strict="false" explicit="true" targetFramework="4.5" />
  <httpRuntime targetFramework="4.5" />
  <customErrors mode="On" defaultRedirect="err_404.html">
    <error statusCode="404" redirect="err_404.html" />
    <error statusCode="403" redirect="err_403.html" />
  </customErrors>
</system.web>

                          

我收到500.19内部服务器错误。我该如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

试试这个

<system.web>
    <customErrors mode="On" redirectMode="ResponseRewrite">
      <error statusCode="500.19" redirect="~/Views/ErrorMessages/Oops.cshtml" />
    </customErrors>
  </system.web>

  <system.webServer>
<httpErrors errorMode="Custom" existingResponse="Replace">
  <remove statusCode="500.19" subStatusCode="-1" />
  <error statusCode="500.19" prefixLanguageFilePath="" path="~/Views/ErrorMessages/Oops.cshtml"
         responseMode="ExecuteURL" />
</httpErrors>
  </system.webServer>