HTTP错误500.19 - 内部服务器错误 - system.webServer/httpErrors缺少部分声明

8 asp.net-mvc iis-7.5 asp.net-mvc-4 asp.net-mvc-5

我有以下内容:

  <system.web>
    <compilation debug="true" targetFramework="4.5"/>
    <httpRuntime targetFramework="4.5"/>
    <customErrors mode="Off"/>   </system.web>
Run Code Online (Sandbox Code Playgroud)

并且:

<system.webServer>
    <handlers>
      <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit"/>
      <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit"/>
      <remove name="ExtensionlessUrlHandler-Integrated-4.0"/>
      <remove name="OPTIONSVerbHandler"/>
      <remove name="TRACEVerbHandler"/>
      <add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0"/>
      <add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0"/>
      <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0"/>
    </handlers>
  </system.webServer>
Run Code Online (Sandbox Code Playgroud)

当我运行我的应用程序时,我收到一个错误页面说:

HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.

Detailed Error Information:
Module     CustomErrorModule
Notification       SendResponse
Handler    Not yet determined
Error Code     0x80070490
Config Error       The configuration section 'system.webServer/httpErrors' cannot be read because it is missing a section declaration
Run Code Online (Sandbox Code Playgroud)

有人可以帮我解释一下.

我想,我不需要有自定义错误页面.但是,我读到的所有内容都告诉我,解决方案是添加自定义错误页面.

Las*_*sen 9

希望以下答案可以帮助后来的人,我将分享我对这个问题的经验.

由于各种原因可能会出现此错误.最近,由于以下原因,我遇到了错误:

  • 缺少URL重写模块.

我的Web.config文件包含一个<rewrite></rewrite>需要安装IIS URL重写模块的部分(可以使用Web Platform Installer完成).

  • Azure SDK的升级.

我的Web.config文件包含以下条目:

<system.diagnostics>
  <sharedListeners>
    <add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener,
               Microsoft.WindowsAzure.Diagnostics,
               Version=2.3.0.0,
               Culture=...
               PublicKeyToken=...">
Run Code Online (Sandbox Code Playgroud)

升级Azure SDK(2.3.x - > 2.6.x)后,无法解决2.3.x版本的"硬"依赖性.为了解决这个问题,我Version完全删除了元素(包括CulturePublicKeyToken),因为在我的情况下,对最新程序集版本的依赖很好.