35

I have installed Elmah for MVC using NuGet, I'am able to login with success error in the db. The only problem is that I cannot access the /elmah URL to access the Error Log Page.

Here part of my configuration, could you please point out if I have any misconfiguration?

Thanks

ERROR

403 - Forbidden: Access is denied.
You do not have permission to view this directory or page using the credentials that you supplied.

In my web.config:

  <appSettings>
    <add key="webpages:Version" value="1.0.0.0" />
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
    <add key="elmah.mvc.disableHandler" value="false" />
    <add key="elmah.mvc.disableHandleErrorFilter" value="false" />
    <add key="elmah.mvc.requiresAuthentication" value="true" />
    <add key="elmah.mvc.allowedRoles" value="Administrator" />
    <add key="elmah.mvc.route" value="elmah" />
  </appSettings>

In global.asax:

    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("elmah.axd");
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        routes.MapRoute(
            "Default", // Route name
            "{controller}/{action}/{id}", // URL with parameters
            new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
        );
    }
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
GibboK
  • 71,848
  • 143
  • 435
  • 658

3 Answers3

50

(This is all from the documentation/getting started)

You don't need the following line:

routes.IgnoreRoute("elmah.axd");

The next line takes care of it.

Everything you need to configure is in your web.config file. Something like:

<elmah>
  <security allowRemoteAccess="yes" />
  <errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="mySqlConnString" />
</elmah>
<location path="elmah.axd">
  <system.web>
    <authorization>
      <allow roles="Administrator" />
      <deny users="*" />
    </authorization>
  </system.web>
</location>

Should get you going.

Erik Philips
  • 53,428
  • 11
  • 128
  • 150
  • Thanks, I'm using MVC are you sure I should use ? Thanks – GibboK Dec 07 '12 at 15:36
  • 9
    It's VERY possible that Emlah has been updated and i'm using an older config. I think the important part is the `allowRemoteAccess` and making sure you are authenticated as jrummell noted. – Erik Philips Dec 07 '12 at 15:37
  • 3
    For MVC you'll use appSettings with entries like . Install this NuGet and it'll modify your config appropriately: https://www.nuget.org/packages/Elmah.MVC – nikib3ro Oct 11 '13 at 22:38
  • He said Elmah MVC. The settings you showed are not for MVC, they are for the earlier version of elmah. The allow remote access string however is required – rollsch Jan 07 '17 at 07:45
  • I only needed this line thanks – Juan Mar 01 '17 at 22:32
  • Saved the day for me as well :) However, in my case it's I'm using elmah 1.2.13605.0 – Jhabar Feb 20 '18 at 07:04
34

Just in case anyone comes across the same issue I had.

This was my code, which is wrong:

<elmah>
    <security allowremoteAccess="true" />
</elmah>

The issue was the r in allowremoteAccess, it was in lower case, when it should have been upper-case!

Correct code:

<elmah>
    <security allowRemoteAccess="true" />
</elmah>
ProxyTech
  • 1,105
  • 8
  • 19
2

Even though I had added the remote access to my web.config:

<add key="elmah.mvc.allowedRoles" value="adminrole" />  

<elmah>
      <security allowRemoteAccess="true" />
      <errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="DefaultConnection" />
      </elmah>

I had to edit Elmah.Athz.config on the server and add the role I wanted to give access to elmah. I had to add ^adminrole

davaus
  • 1,145
  • 13
  • 16