Elmah 无法使用 ASP.NET 网站
我尝试在我的 asp.net 网站上使用 elmah,但每当我尝试访问 http://localhost:port /elmah.axd 我得到资源未找到异常。 我的 web.config 如下。
<?xml version="1.0"?>
<configuration>
<configSections>
<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="0" />
<errorLog type="Elmah.SqlErrorLog, Elmah"
connectionStringName="elmah-sql" />
<errorMail
from="my@account"
to="myself"
subject="ERROR From Elmah:"
async="true"
smtpPort="587"
smtpServer="smtp.gmail.com"
userName="my@account"
password="mypassword" />
</elmah>
<connectionStrings>
<add name="elmah-sql" connectionString="data source=(sqlserver);
database=elmahdb;
integrated security=false;User ID=user;Password=password"/>
</connectionStrings>
<system.web>
<compilation debug="true">
<assemblies>
<add assembly="Elmah, Version=1.0.10617.0, Culture=neutral,
PublicKeyToken=null"/>
</assemblies>
</compilation>
<authentication mode="Windows"/>
<httpHandlers>
<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.asmx" validate="false"
type="System.Web.Script.Services.ScriptHandlerFactory,
System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35"/>
<add verb="*" path="*_AppService.axd" validate="false"
type="System.Web.Script.Services.ScriptHandlerFactory,
System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35"/>
<add verb="GET,HEAD" path="ScriptResource.axd"
type="System.Web.Handlers.ScriptResourceHandler,
System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35" validate="false"/>
</httpHandlers>
<httpModules>
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule,
System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35"/>
</httpModules>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules runAllManagedModulesForAllRequests="true">
<remove name="ScriptModule"/>
<add name="ScriptModule" preCondition="managedHandler"
type="System.Web.Handlers.ScriptModule,
System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35"/>
<add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah"/>
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah"/>
<add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah"/>
</modules>
<handlers>
<remove name="WebServiceHandlerFactory-Integrated"/>
<remove name="ScriptHandlerFactory"/>
<remove name="ScriptHandlerFactoryAppServices"/>
<remove name="ScriptResource"/>
<add name="ScriptHandlerFactory" verb="*" path="*.asmx"
preCondition="integratedMode"
type="System.Web.Script.Services.ScriptHandlerFactory,
System.Web.Extensions, Version=3.5.0.0,
Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add name="ScriptHandlerFactoryAppServices" verb="*"
path="*_AppService.axd" preCondition="integratedMode"
type="System.Web.Script.Services.ScriptHandlerFactory,
System.Web.Extensions, Version=3.5.0.0,
Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add name="ScriptResource" preCondition="integratedMode"
verb="GET,HEAD" path="ScriptResource.axd"
type="System.Web.Handlers.ScriptResourceHandler,
System.Web.Extensions, Version=3.5.0.0,
Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add name="Elmah" verb="POST,GET,HEAD" path="elmah.axd"
preCondition="integratedMode"
type="Elmah.ErrorLogPageFactory, Elmah"/>
</handlers>
</system.webServer>
</configuration>
编辑:Elmah =(错误记录模块和处理程序)
http://code.google.com/p/elmah/
I've tried to use elmah with my asp.net site but whenever I try to go to http://localhost:port/elmah.axd I get resource not found exception. My web.config is given below.
<?xml version="1.0"?>
<configuration>
<configSections>
<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="0" />
<errorLog type="Elmah.SqlErrorLog, Elmah"
connectionStringName="elmah-sql" />
<errorMail
from="my@account"
to="myself"
subject="ERROR From Elmah:"
async="true"
smtpPort="587"
smtpServer="smtp.gmail.com"
userName="my@account"
password="mypassword" />
</elmah>
<connectionStrings>
<add name="elmah-sql" connectionString="data source=(sqlserver);
database=elmahdb;
integrated security=false;User ID=user;Password=password"/>
</connectionStrings>
<system.web>
<compilation debug="true">
<assemblies>
<add assembly="Elmah, Version=1.0.10617.0, Culture=neutral,
PublicKeyToken=null"/>
</assemblies>
</compilation>
<authentication mode="Windows"/>
<httpHandlers>
<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.asmx" validate="false"
type="System.Web.Script.Services.ScriptHandlerFactory,
System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35"/>
<add verb="*" path="*_AppService.axd" validate="false"
type="System.Web.Script.Services.ScriptHandlerFactory,
System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35"/>
<add verb="GET,HEAD" path="ScriptResource.axd"
type="System.Web.Handlers.ScriptResourceHandler,
System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35" validate="false"/>
</httpHandlers>
<httpModules>
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule,
System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35"/>
</httpModules>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules runAllManagedModulesForAllRequests="true">
<remove name="ScriptModule"/>
<add name="ScriptModule" preCondition="managedHandler"
type="System.Web.Handlers.ScriptModule,
System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35"/>
<add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah"/>
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah"/>
<add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah"/>
</modules>
<handlers>
<remove name="WebServiceHandlerFactory-Integrated"/>
<remove name="ScriptHandlerFactory"/>
<remove name="ScriptHandlerFactoryAppServices"/>
<remove name="ScriptResource"/>
<add name="ScriptHandlerFactory" verb="*" path="*.asmx"
preCondition="integratedMode"
type="System.Web.Script.Services.ScriptHandlerFactory,
System.Web.Extensions, Version=3.5.0.0,
Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add name="ScriptHandlerFactoryAppServices" verb="*"
path="*_AppService.axd" preCondition="integratedMode"
type="System.Web.Script.Services.ScriptHandlerFactory,
System.Web.Extensions, Version=3.5.0.0,
Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add name="ScriptResource" preCondition="integratedMode"
verb="GET,HEAD" path="ScriptResource.axd"
type="System.Web.Handlers.ScriptResourceHandler,
System.Web.Extensions, Version=3.5.0.0,
Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add name="Elmah" verb="POST,GET,HEAD" path="elmah.axd"
preCondition="integratedMode"
type="Elmah.ErrorLogPageFactory, Elmah"/>
</handlers>
</system.webServer>
</configuration>
EDIT: Elmah = (Error Logging Modules and Handlers)
http://code.google.com/p/elmah/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
我刚刚遇到了类似的问题,Elmah 无法在 IIS7 部署中工作。 我发现我需要在
system.web
和system.webServer
中注册 Elmah 模块和处理程序:I just had a similar problem with Elmah not working in an IIS7 deployment. I found that I needed to register the Elmah Modules and Handlers in
system.web
ANDsystem.webServer
:您可能也需要这个
当您获得时,
You may be need this one also
when you get
尝试在
部分的“httphandlers”和“httpmodules”部分中注册模块和处理程序:Try registering the Modules and Handlers in the sections "httphandlers" and "httpmodules" in the
<system.web>
section:今天解决这个问题的一种方法是使用 nuget。
Visual Studio:菜单->工具->库包管理器->包管理器控制台
HTH
One way to get around it today is to use nuget.
Visual studio:menu->tools->library package manager->package manager console
HTH
当我使用 NuGet (VS 2013, IIS 8.0) 安装时缺少此行:
添加它解决了 404 错误问题。
This line was missing when I installed using NuGet (VS 2013, IIS 8.0):
Adding it solved the 404 error problem.
nuget 包不会将以下重要行添加到 web.config 中,从而导致 403 错误。
此外,您可能希望通过以下方式限制对错误日志的访问
The nuget package does not add the following important lines to web.config resulting in 403 error.
Also you may want to restrict the access to error logs by
如果您正在使用区域,请确保您已更新应用程序设置键之一
默认值
如果您是区域管理员
if you are using Areas make sure that you have updated one of the appsetting key
Default
If you are an area as Admin