C# Elmah在生产上给出错误代码500,但在旧主机/本地开发上没有给出错误代码500

C# Elmah在生产上给出错误代码500,但在旧主机/本地开发上没有给出错误代码500,c#,elmah,production-environment,C#,Elmah,Production Environment,我不知道如何让Elmah在我的Asp.net MVC项目的生产主机上工作。在本地和我的上一台主机上,所有设置都正确,并转到/Elmah。axd成功地显示错误记录器。然而,在生产主机上,它给了我一个500错误代码。我不知道还要做什么来调试这个问题。我的web.config看起来像: <configSections> <sectionGroup name="elmah"> <section name="security" requirePermission=

我不知道如何让Elmah在我的Asp.net MVC项目的生产主机上工作。在本地和我的上一台主机上,所有设置都正确,并转到
/Elmah。axd
成功地显示错误记录器。然而,在生产主机上,它给了我一个500错误代码。我不知道还要做什么来调试这个问题。我的web.config看起来像:

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

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

<elmah>
  <errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="MyDbContext" />
</elmah>

您可能会忘记使用以下规则更新注册表项:

public static void RegisterRoutes(RouteCollection routes)
{
     routes.IgnoreRoute("elmah.axd");
}

这些链接可能会对您有所帮助,事件日志应该能够为您提供有关错误500的更多信息。显然,最好的办法是将调试器附加到IIS实例,但我猜这是不可能的


另一件需要检查的事情是,这两台服务器是x86还是x64,就像ELMAH是独立于平台的一样,它的一些依赖项不是独立于平台的。

以下是在IIS上调试500错误的方法:

在IE中转到:Internet选项->高级->禁用:显示友好的HTTP错误消息

之后,您将得到一个正常错误,您可以调试:-)



(来源:)

哪个版本的IIS是您的本地主机和生产web服务器?它是IIS7(可能是7.5)。不知道如何找到我的虚拟主机的更多详细信息(我的远程登录功能目前正在失败)不,没有帮助。我的路由已经有一个步骤可以忽略到
.axd
文件的路由