Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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
        );
    }
like image 932
GibboK Avatar asked Dec 07 '12 15:12

GibboK


3 Answers

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

like image 159
Erik Philips Avatar answered Oct 23 '22 04:10

Erik Philips


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>
like image 34
ProxyTech Avatar answered Oct 23 '22 05:10

ProxyTech


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

like image 2
davaus Avatar answered Oct 23 '22 05:10

davaus