Search code examples
.netasp.net-mvc-3exceptionweb-configelmah

Why can't my web project find my elmah.axd file


In my web.config file I have all the references to elmah that I need in order to have elmah running. Except this part of the code:

<location path="elmah.axd">
    <system.web>
        <authorization>
            <allow roles="admin" />
            <deny users="*" />
        </authorization>
    </system.web>
</location>

Either ReSharper or Visual Studio is giving me the error:

Location element is unused: no project found at elmah.axd path:Path to web project\elmah.axd not found

I installed the elmah package from NuGet and I have the dll saved and when I go to the root of my site and type root/elmah.axd I am able to access the elmah logs; however, I need to restrict the access of these logs to admins.

I have two users: Admin and User I want only those with Admin role to access the elmah logs.

Am I missing a piece to this puzzle?


Solution

  • There is nothing wrong... it's just reSharper being a bit silly. Because it can't find a physical file with that name, it thinks it doesn't exist and gives you that error you are seeing.

    You can ignore it by using a ReSharper disable comment like so:

    <!-- ReSharper disable WebConfig.RedundantLocationTag -->
    <!-- ReSharper disable WebConfig.WebConfigPathWarning -->
    <location path="elmah.axd">
    <!-- ReSharper restore WebConfig.WebConfigPathWarning -->
      <system.web>
        <authorization>
          <allow roles="admin" />
          <deny users="*" />
        </authorization>
      </system.web>
    </location>
    <!-- ReSharper restore WebConfig.RedundantLocationTag -->
    

    But it looks ugly ;-)