4

I have an MVC WebAPI site that has the latest ELMAH.MVC NuGet package installed. Under Visual Studio, I can access

http://localhost:1234/elmah

and get the error log, just like I'm supposed to be able to.

When I deploy it to Azure, it throws an error when I do that. Fortunately, Elmah is logging the error to the XmlError log in App_Data, and I found this:

<error errorId="92ad3ee1-3fd5-449a-8cb4-0474aa771aab" 
application="/LM/W3SVC/417796901/ROOT" 
host="RD00155D430783" type="System.Web.HttpException"
message="Server cannot set status after HTTP headers have been sent."
source="System.Web" 
detail="System.Web.HttpException (0x80004005): Server cannot set status after HTTP headers have been sent.&#xD;&#xA;

And then goes on for many lines of stack trace, NONE of which comes anywhere near my code.

What's going on? I've just added the Elmah.MVC nuget package, and made the following changes to the Web.Config

  <elmah>
  <security allowRemoteAccess="yes"/>
      <errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="~/App_Data" />
  </elmah>
  <location path="elmah.axd">
    <system.web>
    <allow roles="*" />
    </system.web>
   </location>

It's not coming anywhere near any of my controllers, so I don't have any control over when Http status headers are set or sent.

Thanks for any help.

tereško
  • 58,060
  • 25
  • 98
  • 150
Dave Hanna
  • 2,491
  • 3
  • 32
  • 52
  • 1
    Have you verified that the App_Data folder was created on the server? – Itanex Mar 22 '13 at 03:04
  • That error would indicate buffering is off & that something started sending data back to the client when something tried to change the headers, say to redirect. Can't say why elmah might be doing that. – Simon Halsey Apr 07 '13 at 11:19
  • 1
    You say you are using `http://localhost:1234/elmah` but your config says `elmah.axd`. have you tried accessing elmah.axd directly? – Simon Halsey Apr 07 '13 at 11:20
  • Elmah.Mvc has settings that are set in appSettings, the elmah configSection might work but I'd also make sure you don't have conflicting settings in your appSettings. – Khalid Abuhakmeh May 09 '13 at 17:27
  • duplicate of http://stackoverflow.com/questions/11674464/cant-access-elmah-on-production-server-with-elmah-mvc? If so see answer below... – drzaus Oct 04 '13 at 13:43

2 Answers2

0

itanex is right! Put an empty text file (i.e. placeholder.txt) in the App_Data folder and mark it as "Content" and "Always Copy" - This will ensure that the App_Data folder is getting created. Also, as Simon point out, the correct path (based on your config) is /elmah.axd

viperguynaz
  • 12,044
  • 4
  • 30
  • 41
0

via https://stackoverflow.com/a/11680786/1037948:

Allow remote access:

<elmah>
      <security allowRemoteAccess="true"/>
</elmah>
Community
  • 1
  • 1
drzaus
  • 24,171
  • 16
  • 142
  • 201