http-status-code-404elmahektron

Ektron and Elmah - 404 Errors not being logged


I am currently configuring ELMAH 1.2 to log errors within our Ektron 9.1 application, however it will not log any 404 errors. ELMAH is currently functional as it is logging other errors (including unhandled exceptions), just not 404 errors. I am not running an MVC environment / 3-Tier Ektron Architecture, we are still using the traditional ASP.NET / Ektron Web Forms solution.

I know ELMAH logs these errors by default, so I'm wondering if I'm missing something with regards to how ELMAH is interacting with Ektron. There's not much information out there on the topic, and the one article I found is dated from 2010, so the information is severely outdated.


Solution

  • It's different for URLs that end in .aspx and other ones. If a user goes to your site and accesses /ThisFileisnothere.html The static file handler would handle that. Ektron replaces the static file handler with the EkDavHttpHandlerFactory. Ektron's handler doesn't throw an exception. It doesn't trigger an Application.Error Event. It just sets the statusCode to 404. If you wanted to do something custom like log an error to ELMAH, you could hook the Application.PostRequestHandlerExecute and check the Response.StatusCode

    If a user tries to go to /ThisPageisntHere.ASPX then a different handler will handle that URL and will trigger the Application.Error event that ELMAH should catch.