Elmah.axd - 在IIS Express和IIS上都出现错误404

时间:2012-05-14 14:30:27

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

有人可以建议为什么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>

3 个答案:

答案 0 :(得分:8)

从它的外观来看,我相信你的配置是错误的。您在<httpModules />的上下文之外定义<httpHandlers /><system.web />。此外,您还需要在<system.webServer />中为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示例。

答案 1 :(得分:0)

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

routes.IgnoreRoute("elmah.axd");

答案 2 :(得分:-2)

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

这就是我们配置的内容:

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

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