Can't access /elmah on production server with Elmah MVC?

C#asp.net MvcElmahHttp Status-Code-403

C# Problem Overview


I installed the elmah.mvc nuget package and kept the default configuration of that sans setting up sending an email and plugging it into a SQL database.

On my local machine when I use the Visual Studio host, I can open my app and access /elmah fine to see a report of the errors. However, when I try and access /elmah on production, I get two errors, first I get a 403 access is denied server error. Then in my email (from elmah) I get:

System.Web.HttpException: Server cannot set status after HTTP headers have been sent.

Anyone know what is going on here and how to fix? Thanks.

I tried the following so far as suggested by the answers below:

In <system.webServer>

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

And in <system.web>

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

I tried setting the path to both elmah.axd and simply ~/elmah. All still give the same error, and still works locally, but not in production.

Edit: It actually also works when I remote into the server and access it via browser on there (not using localhost, but the actual site address). So what permission am I not having? Seems like it's at the server level.

C# Solutions


Solution 1 - C#

You need to enable Elmah for remote access by adding the following configuration setting to the <elmah> section in your web.config file. The default setting for this value is false, which only allows localhost, hence why it is working on your local machine from within Visual Studio.

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

I always seem to forget this myself and spend a few minutes scratching my head ;)

Solution 2 - C#

Make sure you HttpHandler is defined in the webServer section in your web.config file.

<system.webServer>
  <httpHandlers>
    <add name="elmah" verb="GET" path="elmah.axd"  type="Elmah.ErrorLogPageFactory, Elmah"/>
  </httpHandlers>
</system.webServer>

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSventoryMangView Question on Stackoverflow
Solution 1 - C#Paige CookView Answer on Stackoverflow
Solution 2 - C#scottmView Answer on Stackoverflow