【问题标题】:Elmah webconfig error 500 on Window2008r2 MVC2 ProjectWindow2008r2 MVC2 项目上的 Elmah webconfig 错误 500
【发布时间】:2010-11-29 06:03:24
【问题描述】:

刚刚发现我不需要 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" />

...

【问题讨论】:

    标签: asp.net-mvc-2 elmah sql-server-2008-r2


    【解决方案1】:

    我猜你在 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>
    

    【讨论】:

      【解决方案2】:

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

      【讨论】:

        猜你喜欢
        • 2011-03-20
        • 2011-03-19
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-03-26
        • 2020-04-07
        • 2015-03-09
        • 2016-10-18
        相关资源
        最近更新 更多