Elmah does not work with asp.net website

I tried to use elmah with my asp.net site, but whenever I try to go to http: // localhost: port / elmah.axd , I don't get the exception resource. My web.config is 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/

+78
exception-handling elmah
Jun 01 '09 at 4:22
source share
7 answers

Try registering the modules and handlers in the "httphandlers" and "httpmodules" sections in the <system.web> section:

  <httpHandlers> ...... <add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah"/> ..... </httpHandlers> <httpModules> ....... <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah"/> <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah"/> <add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah"/> ....... </httpModules> 
+28
Jun 01 '09 at 4:47
source share

I had a similar problem with Elmah not working in IIS7 deployment. I found that I need to register Elmah modules and handlers in system.web AND system.webServer :

 <system.web> ... <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" /> <add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" /> ... </httpModules> ... </system.web> <system.webServer> ... <modules runAllManagedModulesForAllRequests="true"> ... <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah"/> <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" /> <add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" /> ... </modules> <handlers> ... <add name="Elmah" verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" /> ... </handlers> <system.webServer> 
+152
Jul 23 '09 at 23:18
source share

You may also need

 <elmah> <security allowRemoteAccess="1" /> </elmah> 

when you get

403 - Forbidden: Access denied. You do not have permission to view this directory or the page with which you have provided.

+119
Nov 05 '09 at 7:20
source share

This line was missing when I installed using NuGet (VS 2013, IIS 8.0):

 <system.webServer> <handlers> <add name="Elmah" verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" /> </handlers> </system.webServer> 

Adding this solution fixes the 404 error issue.

+12
Dec 26 '13 at 18:39
source share

One way around this today is to use nuget.

Visual studio: menu-> tools-> library package manager-> package manager console

 install-package elmah 

NTN

+10
Jul 15 '11 at 6:45
source share

The nuget package does not add the following important lines to the web.config file, resulting in a 403 error.

 <configuration> <elmah> <security allowRemoteAccess="1" /> <errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="~/app_data/elmah" /> </elmah> </configuration> 

You can also restrict access to error logs with

 <add name="Elmah" verb="POST,GET,HEAD" path="/admin/elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode" /> 
+9
Nov 29
source share

if you use areas make sure you update one of the appsetting keys

Default

 <add key="elmah.mvc.route" value="elmah" /> 

If you are a member of Admin

 <add key="elmah.mvc.route" value="admin/elmah" /> 
0
Jul 21 '17 at 9:56 on
source share



All Articles