Elmah not working with asp.net site

后端 未结 7 636
抹茶落季
抹茶落季 2020-11-27 10:02

I\'ve tried to use elmah with my asp.net site but whenever I try to go to http://localhost:port/elmah.axd I get resource not found exception. My web.config is given below.

相关标签:
7条回答
  • 2020-11-27 10:41

    One way to get around it today is to use nuget.

    Visual studio:menu->tools->library package manager->package manager console

    install-package elmah
    

    HTH

    0 讨论(0)
  • 2020-11-27 10:44

    I just had a similar problem with Elmah not working in an IIS7 deployment. I found that I needed to register the Elmah Modules and Handlers in system.web AND system.webServer:

    <system.web>
    ...
      <httpHandlers>
        ...
        <add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
        ...
      </httpHandlers>
      <httpModules>
        ...
        <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah"/>
        <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" />
        <add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" />
        ...
      </httpModules>
      ...
    </system.web>
    <system.webServer>
      ...
      <modules runAllManagedModulesForAllRequests="true">
        ...
        <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah"/>
        <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" />
        <add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" />
        ...
      </modules>
      <handlers>
        ...
        <add name="Elmah" verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
        ...
      </handlers>
    <system.webServer>
    
    0 讨论(0)
  • 2020-11-27 10:46

    The nuget package does not add the following important lines to web.config resulting in 403 error.

    <configuration>
      <elmah>  
        <security allowRemoteAccess="1" />
        <errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="~/app_data/elmah" />
      </elmah>
    </configuration>
    

    Also you may want to restrict the access to error logs by

    <add name="Elmah" verb="POST,GET,HEAD" path="/admin/elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode" />
    
    0 讨论(0)
  • 2020-11-27 10:52

    if you are using Areas make sure that you have updated one of the appsetting key

    Default

    <add key="elmah.mvc.route" value="elmah" />
    

    If you are an area as Admin

    <add key="elmah.mvc.route" value="admin/elmah" />
    
    0 讨论(0)
  • 2020-11-27 10:53

    Try registering the Modules and Handlers in the sections "httphandlers" and "httpmodules" in the <system.web> section:

        <httpHandlers>
          ......
        <add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah"/>
          .....
    
        </httpHandlers>
        <httpModules>
            .......
            <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah"/>
            <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah"/>
            <add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah"/>
           .......
        </httpModules>
    
    0 讨论(0)
  • 2020-11-27 10:54

    This line was missing when I installed using NuGet (VS 2013, IIS 8.0):

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

    Adding it solved the 404 error problem.

    0 讨论(0)
提交回复
热议问题