1

刚刚发现我不需要 httpHandler 和 system.web 中的 httpHandlers 并且它仍在运行

我试图将 Elmah 集成到我的 MVC2 项目中,它在我的本地运行良好,但是当我将它上传到 Web 时,即 window2008-r2。我得到“500 - 内部服务器错误”。

当我从 webconfig 中删除 httpHandler 和 httpHandlers 时,错误消失了,但 elmah 没有运行。

请帮忙,我如何让它在 2008RC 上运行?

这是我的 webconfig 文件中的内容:

  <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"/>
  <section name="errorTweet" requirePermission="false" type="Elmah.ErrorTweetSectionHandler, Elmah"/>
</sectionGroup>

……

<httpModules>
  <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah"/>
  <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" />
</httpModules>


<customErrors mode="RemoteOnly" defaultRedirect="/content/error.htm" />

……

<modules runAllManagedModulesForAllRequests="true">
  <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah"/>
  <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" />
</modules>


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

...

<security allowRemoteAccess="0" />

<!--
  quickest log method
  -->
<errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="~/Content/ErrorLog" />

...

4

2 回答 2

0

system.web 中是否需要 httpHandlers 取决于您是否在 IIS6 上......最好保留这两个部分,如odyth示例中所示,以便它适用于 IIS 6 和 7

于 2011-01-21T20:38:35.430 回答
0

我猜你在你的 2008 机器上使用 .net 4.0,这个模块与 .net 4 不兼容

我所做的是下载源文件并将其编译为 .net 4 并且没有问题。我目前正在使用 .net 4.0 在服务器 2008 上运行 Elmah,一切正常。

就像这里的参考是我的 web.config 文件的摘录

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

<elmah>
  <errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="ConnectionString" />
  <security allowRemoteAccess="0" />    
</elmah>
<location path="elmah.axd">
<system.web>
    <authorization>
      <deny users="?" />
    </authorization>
    <httpRuntime requestLengthDiskThreshold="256" maxRequestLength="2097151" />
  </system.web>
</location>

<system.web>
<httpHandlers>
  <add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />      
</httpHandlers>

<httpModules>
  <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" />
</httpModules>
</system.web>

<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules runAllManagedModulesForAllRequests="true">
  <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah"/>
</modules>
<handlers>
  <add name="Elmah" verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
 </handlers>
 </system.webServer>
于 2011-01-20T03:30:04.617 回答