3
votes

Background / Goal

I have an asp.net 4.5 web forms project that's now under the asp.net one architecture (so we're integrating MVC in a few parts).

I am attempting to add Elmah to this setup. My goals are:

  • to log 50 errors in memory, with local access only,
  • to log all errors to a SQL database (which we've set up with the Elmah scripts).
  • To capture both WebForms and MVC error output into Elmah.

Problem

However, when I add the Elmah package via nuget, it does not appear to make any modifications to web.config. So, when I browse to /elmah.axd, I see:

Path '/elmah.axd' was not found. System.Web.HttpException (0x80004005): Path '/elmah.axd' was not found. at System.Web.HttpNotFoundHandler.ProcessRequest(HttpContext context) at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

This makes sense, because web.config hasn't been modified to add the handlers.

However, adding elmah.axd does give us an MVC route. However, my instincts and some rudimentary tests tell me that these only cover errors within the purview of MVC.

Question(s)

  • How can I properly configure elmah in this instance so that elmah and elmah.mvc packages both worth as desiged?
2
Which ELMAH NuGet package are you adding? - ThomasArdal
I'd done Install-Package Elmah and eventually I did Install-Package Elmah.MVC, but that was after already configuring the XML. - SeanKilleen
The Elmah package on its own should add the config. Elmah.Mvc does some other things like declaring a /elmah URL (instead of elmah.axd). - ThomasArdal
@ThomasArdal correct, that's the impression I got. So I'm wondering why my web.config isn't modified at all. (after elmah package is installed, web.config has no mention of the word 'elmah' and a diff appears mostly the same (though it does seem to do things like remove spaces before tag closings, etc.) - SeanKilleen

2 Answers

1
votes

it could be related to the existing sections/elements of your original web.config file, so that the web.config.transform in the Elmah package could not perform some of the add operations.

This document - http://docs.nuget.org/docs/creating-packages/configuration-file-and-source-code-transformations described explicitly what the Elmah package transformation will do, for web.config before and after.

0
votes

Well this happened to me too, I did 3 things.

  1. Went to "Manage NuGet Packages" for your project, delete everything about Elmah.
  2. Restarted visual studio, and opened it with admin priviliges. ( not sure if it was this). Make sure your web.config is not opened, for some reason VS was not updating it.
  3. Run install-package elmah on Package Manager Console again.

And after that my web config is updated and everything runnning smoothly.