【问题标题】:Elmah.axd - getting error 404 on both IIS Express and IISElmah.axd - 在 IIS Express 和 IIS 上都出现错误 404
【发布时间】:2012-05-22 01:22:29
【问题描述】:

谁能指出为什么 elmah 错误页面没有显示,我收到错误 404。我正在使用 IISExpress。我确定我有这个工作并且不记得对 web.config 进行任何更改以阻止它工作。

我的配置文件:

<configuration>
  <configSections>
    <sectionGroup name="elmah">
      <section name="security" requirePermission="false" type="Elmah.SecuritySectionHandler, Elmah" />
      <section name="errorLog" requirePermission="false" type="Elmah.ErrorLogSectionHandler, Elmah" />
      <section name="errorMail" requirePermission="false" type="Elmah.ErrorMailSectionHandler, Elmah" />
      <section name="errorFilter" requirePermission="false" type="Elmah.ErrorFilterSectionHandler, Elmah" />
    </sectionGroup>
  </configSections>
  <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.webServer>
 <modules runAllManagedModulesForAllRequests="true">
      <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" preCondition="managedHandler" />
 </modules>
</system.webServer>
<elmah>
   <errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="~/App_Data" />
</elmah>
</configuration>

【问题讨论】:

    标签: asp.net asp.net-mvc elmah


    【解决方案1】:

    从外观上看,我相信你的配置是错误的。您在&lt;system.web /&gt; 的上下文之外定义&lt;httpModules /&gt;&lt;httpHandlers /&gt;。此外,您还需要在 &lt;system.webServer /&gt; 中定义您的处理程序以支持 IIS 7+。试试这个:

    <configuration>
        <configSections>
            <sectionGroup name="elmah">
                <section name="security" requirePermission="false" type="Elmah.SecuritySectionHandler, Elmah" />
                <section name="errorLog" requirePermission="false" type="Elmah.ErrorLogSectionHandler, Elmah" />
                <section name="errorMail" requirePermission="false" type="Elmah.ErrorMailSectionHandler, Elmah" />
                <section name="errorFilter" requirePermission="false" type="Elmah.ErrorFilterSectionHandler, Elmah" />
            </sectionGroup>
        </configSections>
        <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>
            <handlers>
                <add name="Elmah" verb="POST,GET,HEAD" path="elmah.axd" preCondition="integratedMode" type="Elmah.ErrorLogPageFactory, Elmah" />
            </handlers>
            <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>
        </system.webServer>
        <elmah>
            <errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="~/App_Data" />
        </elmah>
    </configuration>
    

    检查 this link 以获取 ELMAH 1.2 的有效 Web.config 示例。

    【讨论】:

    • 此错误在 IIS Express 上也可见,但可以通过查看项目属性 - 管理管道模式设置(设置为经典)来解决。在 IIS7 上部署需要 System.webServer 设置,并将管理管道模式设置为集成。更多信息请看这篇文章:ozkary.com/2015/12/404-error-axd-http-handler.html
    【解决方案2】:

    你还在忽略路由中的 Elmad.axd 吗?这可能是使用 MVC 时的问题。

    routes.IgnoreRoute("elmah.axd");
    

    【讨论】:

    • 是的,我忽略了这条路线。
    【解决方案3】:

    不确定这是否有帮助,但您的 web.config 中是否设置和配置了错误页面?

    这是我们配置的:

    <customErrors mode="RemoteOnly" defaultRedirect="ErrorPage.htm"></customErrors>
    

    在我们的应用程序的主目录中有一个随附的 errorpage.htm 文件。

    【讨论】:

    • 这个答案与 ELMAH 并不特别相关。
    猜你喜欢
    • 2012-07-13
    • 1970-01-01
    • 2012-07-24
    • 1970-01-01
    • 2013-02-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多