17

I'm trying to use elmah for my MVC application and I've followed the steps on the wiki: http://code.google.com/p/elmah/wiki/MVC , but even so when trying to access myapp/elmah.axd the page:

404 - File or directory not found.

Anyone could help me please?

OBS: My IIS Version is 7.5


If helps I'm posting the pertinent sections of my web.config:

<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>
...
</connectionStrings>
<elmah>
  <errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="~/App_Data" />
</elmah>
<system.web>
...
<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" />
  <add verb="*" path="*.mvc" validate="false" type="System.Web.Mvc.MvcHttpHandler, System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
  <add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
</httpHandlers>
<httpModules>
  <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
  <add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
  <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" />
  <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" />            
  <add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" />
</httpModules>

And on my Global.asax.cs

public static void RegisterRoutes(RouteCollection routes)
{   
  routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
...
2
  • What version of IIS are you using? I only ask because maybe the handler isn't in the right .config section. In IIS7 it needs to be in the <system.webServer><handlers> section. Could be something else entirely... Commented Jan 22, 2010 at 15:29
  • Thank you guys, I'm using IIS 7.5 Commented Jan 22, 2010 at 15:30

4 Answers 4

14

You need to populate the system.webServer config section also, for IIS 7+. See this question.

Sign up to request clarification or add additional context in comments.

Comments

6

Here's a nice way of using ELMAH in MVC here that doesn't use the axd but a controller and a custom ElmahActionResult.

1 Comment

This is great (NuGet just didn't put in the right config for me) but you should lift out the main code parts and paste them here to avoid link-rot on SO. Thanks for the solution.
1

Try adding this to your web.config file in the

<system.webServer>

    <handlers>
        <remove name="ErrorLog" />
        <remove name="ErrorMail" />
        <remove name="ErrorFilter" />
        <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" />
        <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" />            
        <add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" />     
    </handlers>       
</system.webServer>

1 Comment

Config Error Missing required attribute 'path'
1

To help others experiencing what @zanona ran up against way back in 2010 (see comments to @hunter's reply above), the following change fixed the very same "HTTP Error 500.19 - Internal Server Error" for me today. Notice the placement of the configuration tags in @hunter's reply is what caused @zanona's error. Those tags @hunter mentioned belong under the modules heading, not the handlers one!

<modules>
  <remove name="ErrorLog" />
  <remove name="ErrorMail" />
  <remove name="ErrorFilter" />
  <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" />
  <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" />            
  <add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" /> 
 </modules>       

The above fix eliminated for me the very same "Config Error - Missing required attribute 'path'" issue that @zanona first reported. That error came as a result of the way tags in the handlers group are expected to be structured, and his rearranged tags caused obviously didn't have the path attribute (because they didn't belong there, but rather belong under the modules tag!). Now here's what tags in the handlers section should look like:

<handlers>

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

</handlers>

Notice the path attribute is present there? Ah!

Thanks to @hunter and @zanona because they did set me on the path I needed to solve my issue.

(NOTE: I've tried to edit the original post from @hunter above to make the corrections but peer review is slow and I thought I'd keep this reply here to help anyone facing the same challenge in the meanwhile. When that edit is accepted, we could delete this post.)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.