asp.net-mvcelmahelmah.mvc

ELMAH - MVC 3 - 403 - Forbidden: Access is denied


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
        );
    }

Solution

  • (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.