2

For my MVC4 application I have used NUGET to load ELMAH into my application. But in the web.config I get the following error message:

Location element is unused; no project item found at elmah.axd.

Am I meant to create a file with this name? How do I fix this?

<location path="elmah.axd" inheritInChildApplications="false">
    <system.web>
      <httpHandlers>
        <add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
      </httpHandlers>


        See http://code.google.com/p/elmah/wiki/SecuringErrorLogPages for 
        more information on using ASP.NET authorization securing ELMAH.

      <authorization>
        <allow roles="admin" />
        <deny users="*" />  
      </authorization>


    </system.web>
    <system.webServer>
      <handlers>
        <add name="ELMAH" verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" preCondition="integratedMode" />
      </handlers>
    </system.webServer>
  </location>
levelnis
  • 7,665
  • 6
  • 37
  • 61
arame3333
  • 9,887
  • 26
  • 122
  • 205

3 Answers3

4

If you use Elmah.MVC.dll there is no need to add the handler for elmah.axd. Elmah.MVC.dll includes a controller enabling you to access your logs at http://www.yourwebsite.com/elmah. This is described fully at:

https://github.com/alexanderbeletsky/elmah.mvc

I recommend this approach because it's simpler to configure than the elmah.axd handler.

traceagent
  • 61
  • 1
  • I am using the nuget download of Elmah MVC that you refer to which generates this code in the web.config. I am finding that when I comment out the above code I can access elmah.axd as a webpage. However I am not picking up the css styles. So I am wondering why this is happening – arame3333 Mar 14 '13 at 07:40
  • 1
    The changes to the web.config shown in the question are not added by the elmah.mvc nuget package. They are added if you add the elmah nuget package directly. I recommend uninstalling all elmah related nuget packages (which should clean up the web.config file). Then reinstall elmah.mvc package only. This will add the necessary settings to web.config which will not include the modification. The big difference here is that elmah.mvc does not install the elmah package, only elmah.corelibrary and elmah.mvc – Paige Cook Mar 14 '13 at 12:34
  • Well that has done the job so thank you for that. One issue I have however is that the CSS styles are not being picked up on the webpage that shows the Elmah errors. I tried copying the code, but perhaps surprisingly I got the error message tha the code is already installed via Nuget. So why would it not pick up the styles? – arame3333 Mar 18 '13 at 08:43
0

You need to add the following in RegisterRoutes :

routes.IgnoreRoute("elmah.axd/{*pathInfo}");

Peter Bernier
  • 8,038
  • 6
  • 38
  • 53
0

I installed Elmah.MVC through NuGet.

Most of the web.config settings were automatically added by the install.

Had to add:

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

and:

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

then at the very bottom of the config there will be an empty section so I modified it to:

<elmah>
    <errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="~/App_Data" />
</elmah>

and logging to an XML file worked!

Note, you may have to tweak logPath if it isn't appropriate.

Gina! VS2012, MVC4, all updates/sp applied

Gina Marano
  • 1,773
  • 4
  • 22
  • 42