试图实施 ELMAH - 不断收到 IIS HTTP 500.22 错误
Posted
技术标签:
【中文标题】试图实施 ELMAH - 不断收到 IIS HTTP 500.22 错误【英文标题】:Tried to implement ELMAH - keep getting IIS HTTP 500.22 Error 【发布时间】:2012-11-30 14:42:00 【问题描述】:我的 web.config 中有以下内容:
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<sectionGroup name="elmah">
<section name="security" requirePermission="false"
type="Elmah.SecuritySectionHandler, Elmah" />
<section name="errorLog" requirePermission="false"
type="Elmah.ErrorLogSectionHandler, Elmah" />
<section name="errorMail" requirePermission="false"
type="Elmah.ErrorMailSectionHandler, Elmah" />
<section name="errorFilter" requirePermission="false"
type="Elmah.ErrorFilterSectionHandler, Elmah" />
</sectionGroup>
</configSections>
<elmah>
<security allowRemoteAccess="yes" />
<errorLog type="Elmah.SqlErrorLog, Elmah"
connectionStringName="PhumafConnectionString" />
<errorMail
from="*******"
to="*********"
subject="Application Exception"
async="false"
smtpPort="0"
useSsl="true" />
</elmah>
<system.net>
<mailSettings>
<smtp deliveryMethod="Network">
<network host="smtp.gmail.com" port="587" userName="*********" password="********" />
</smtp>
</mailSettings>
</system.net>
<connectionStrings>
<add name="PhumafEntities" connectionString="metadata=res://*/PhumafDB.csdl|res://*/PhumafDB.ssdl|res://*/PhumafDB.msl;provider=System.Data.SqlClient;provider connection string="data source=DRAGAN-THINK\SQLEXPRESS;initial catalog=Phumaf;integrated security=True;multipleactiveresultsets=True;application name=EntityFramework""
providerName="System.Data.EntityClient" />
<add name="PhumafConnectionString" connectionString="Data Source=DRAGAN-THINK\SQLEXPRESS;Initial Catalog=Phumaf;Integrated Security=True;MultipleActiveResultSets=True;Application Name=EntityFramework"
providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<customErrors mode="On" defaultRedirect="~/genericError.aspx">
<error statusCode="404" redirect="~/404.aspx" />
</customErrors>
<httpHandlers>
<add verb="POST,GET,HEAD" path="elmah.axd"
type="Elmah.ErrorLogPageFactory, Elmah" />
</httpHandlers>
<httpModules>
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" />
<add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" />
</httpModules>
<compilation debug="true" targetFramework="4.5">
<assemblies>
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</assemblies>
</compilation>
<httpRuntime targetFramework="4.5" />
</system.web>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
</entityFramework>
</configuration>
我还将 Elmah.dll 添加到 bin 文件夹中。每当我运行应用程序时,我都会收到包含以下消息的 IIS 错误屏幕:
HTTP Error 500.22 - Internal Server Error
An ASP.NET setting has been detected that does not apply in Integrated managed pipeline mode.
Most likely causes:
This application defines configuration in the system.web/httpModules section.
Detailed Error Information:
Module ConfigurationValidationModule
Notification BeginRequest
Handler PageHandlerFactory-Integrated-4.0
Error Code 0x80070032
Requested URL http://localhost:13094/index.aspx
Physical Path c:\users\dragan\documents\visual studio 2012\Projects\WebApplication2\WebApplication2\index.aspx
Logon Method Not yet determined
Logon User Not yet determined
Request Tracing Directory C:\Users\Dragan\Documents\IISExpress\TraceLogFiles\WEBAPPLICATION2
验证我的 XML 有效并且 100% 有效:/
我真的不知道出了什么问题。在我尝试实现 Elmah 之前,一切都还好。我开始失去理智了,如果你看到我做错了,请帮忙。
【问题讨论】:
我没有立即发现任何问题,但我建议您开始注释掉 web.config 的部分内容,直到您将其范围缩小到它所抱怨的内容为止。跨度> 当我注释掉 httphandlers 和 httpmodules 部分时,我得到了索引。我忽略了他们中的任何一个我得到了同样的错误:/ 【参考方案1】:查看以下两个链接 http://code.google.com/p/elmah/issues/detail?id=231
和
http://mvolo.com/breaking-changes-for-aspnet-20-applications-running-in-integrated-mode-on-iis-70
解决这个错误的关键部分如下
1) 在 或 中指定配置时,ASP.NET 应用程序需要迁移。 您将收到 500 – 内部服务器错误。这可能包括 HTTP 错误 500.22 和 HTTP 错误 500.23:检测到不适用于集成托管管道模式的 ASP.NET 设置。 这是因为 ASP.NET 模块和处理程序应在集成模式下的 IIS 和配置部分中指定。 解决方法: 1) 您必须迁移应用程序配置才能在集成模式下正常工作。您可以使用 AppCmd 迁移应用程序配置:
%windir%system32inetsrvAppcmd 迁移配置“”
【讨论】:
【参考方案2】:另一种选择是在 httphandlers 之后添加到 web.config。
例如
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
<add name="Access-Control-Allow-Headers" value="*" />
<add name="Access-Control-Allow-Methods" value="GET, POST, PUT, DELETE, OPTIONS" />
</customHeaders>
</httpProtocol>
<handlers>
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<remove name="OPTIONSVerbHandler" />
<remove name="TRACEVerbHandler" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true">
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" preCondition="managedHandler" />
<add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" preCondition="managedHandler" />
<add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" preCondition="managedHandler" />
</modules>
</system.webServer>
【讨论】:
以上是关于试图实施 ELMAH - 不断收到 IIS HTTP 500.22 错误的主要内容,如果未能解决你的问题,请参考以下文章
无法让 ELMAH 在 IIS7.5 上与 ASP.NET MVC2 一起使用
为啥会收到奇怪的错误消息 asp.net mvc "elmah.mvc logging library"?