asp.net - asp.net MVC3 中的错误处理

标签 asp.net asp.net-mvc

我创建了一个 MVC3 应用程序并在 web.config 中添加了 cutomerrors 属性 on。它适用于 chrome 和 Firefox 但是当我在 IE9 中运行它时,我得到

网站无法显示页面

HTTP 500

最可能的原因: •网站维护中。 •网站有程序错误。

你可以尝试什么:

<?xml version="1.0"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=152368
  -->

<configuration>
  <appSettings>
    <add key="ClientValidationEnabled" value="true"/> 
    <add key="UnobtrusiveJavaScriptEnabled" value="true"/> 
  </appSettings>

  <system.web>
      <customErrors mode="On"></customErrors>
    <compilation debug="true" targetFramework="4.0">
      <assemblies>
        <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
      </assemblies>
    </compilation>

    <authentication mode="Forms">
      <forms loginUrl="~/Account/LogOn" timeout="2880" />
    </authentication>

    <pages>
      <namespaces>
        <add namespace="System.Web.Helpers" />
        <add namespace="System.Web.Mvc" />
        <add namespace="System.Web.Mvc.Ajax" />
        <add namespace="System.Web.Mvc.Html" />
        <add namespace="System.Web.Routing" />
        <add namespace="System.Web.WebPages"/>
      </namespaces>
    </pages>
  </system.web>

  <system.webServer>
    <validation validateIntegratedModeConfiguration="false"/>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>

  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

最佳答案

Internet Explorer 版本中存在一个已知问题,自定义错误页面必须至少为 512 字节。虽然这通常适用于旧的 IE 版本并且通常会导致 404 错误页面,但我建议确保您的自定义错误页面大小为 1 kB。您可能会放入一些 HTML 注释或其他内容。只是为了确保它与那个旧的 IE 错误无关。

只是众多引用中的一个: http://perishablepress.com/press/2008/01/21/important-note-for-your-custom-error-pages/

关于asp.net - asp.net MVC3 中的错误处理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5349867/

相关文章:

jquery - 如何使用jquery获取Datalist控件的clientID

asp.net - 获取 .NET 中特定 div 内的控件列表

asp.net - 使用 MVC 的属性路由和 RouteLocalization.mvc 的特定于语言的默认 URL

jquery - 使用 Jquery 无需进入服务器即可更改按钮的图像

c# - 具有 2 个或 3 个级别的 MVC URL 路由

c# - 在引用的 C# 库中,有没有办法知道父项目是 Debug 还是 Release?

asp.net - 使用 JavaScript 和 jQuery 获取嵌入 ASP 对象的 ID

c# - 如何使用 JQuery 获取母版页中控件的值?

asp.net - 跨 ASP.NET 的多个数据库维护用户数据完整性

javascript - ASP.NET MVC 将模型传递给 KnockoutJS 外部文件