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

China☆狼群 提交于 2019-11-27 05:26:57

问题


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.


回答1:


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




回答2:


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>


来源:https://stackoverflow.com/questions/11674464/cant-access-elmah-on-production-server-with-elmah-mvc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!