Elmah 不使用 asp.net 网站

Elmah not working with asp.net site(Elmah 不使用 asp.net 网站)

本文介绍了Elmah 不使用 asp.net 网站的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在我的 asp.net 站点中使用 elmah,但每当我尝试访问 http://localhost:port/elmah.axd 我得到资源未找到异常.我的 web.config 如下所示.

I've tried to use elmah with my asp.net site but whenever I try to go to http://localhost:port/elmah.axd I get resource not found exception. My web.config is given below.

    <?xml version="1.0"?>
    <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>
      <elmah>
        <security allowRemoteAccess="0" />
        <errorLog type="Elmah.SqlErrorLog, Elmah" 
                 connectionStringName="elmah-sql" />
        <errorMail
                from="my@account"
                to="myself"
                subject="ERROR From Elmah:"
                async="true"
                smtpPort="587"
                smtpServer="smtp.gmail.com"
                userName="my@account"
                password="mypassword" />
      </elmah>

      <connectionStrings>
        <add name="elmah-sql" connectionString="data source=(sqlserver); 
               database=elmahdb;
             integrated security=false;User ID=user;Password=password"/>
      </connectionStrings>
      <system.web>
        <compilation debug="true">
          <assemblies>
            <add assembly="Elmah, Version=1.0.10617.0, Culture=neutral, 
               PublicKeyToken=null"/>
          </assemblies>
        </compilation>
        <authentication mode="Windows"/>

        <httpHandlers>
          <remove verb="*" path="*.asmx"/>
          <add verb="*" path="*.asmx" validate="false" 
            type="System.Web.Script.Services.ScriptHandlerFactory, 
               System.Web.Extensions, Version=3.5.0.0, Culture=neutral, 
                  PublicKeyToken=31BF3856AD364E35"/>
          <add verb="*" path="*_AppService.axd" validate="false" 
               type="System.Web.Script.Services.ScriptHandlerFactory, 
               System.Web.Extensions, Version=3.5.0.0, Culture=neutral, 
                   PublicKeyToken=31BF3856AD364E35"/>
          <add verb="GET,HEAD" path="ScriptResource.axd" 
                 type="System.Web.Handlers.ScriptResourceHandler, 
               System.Web.Extensions, Version=3.5.0.0, Culture=neutral, 
                    PublicKeyToken=31BF3856AD364E35" validate="false"/>
        </httpHandlers>
        <httpModules>
          <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, 
                System.Web.Extensions, Version=3.5.0.0, Culture=neutral, 
                PublicKeyToken=31BF3856AD364E35"/>
        </httpModules>
      </system.web>

      <system.webServer>
        <validation validateIntegratedModeConfiguration="false"/>
        <modules runAllManagedModulesForAllRequests="true">
          <remove name="ScriptModule"/>
          <add name="ScriptModule" preCondition="managedHandler" 
                type="System.Web.Handlers.ScriptModule, 
               System.Web.Extensions, Version=3.5.0.0, Culture=neutral, 
                 PublicKeyToken=31BF3856AD364E35"/>
          <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah"/>
          <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah"/>
          <add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah"/>
        </modules>

        <handlers>
          <remove name="WebServiceHandlerFactory-Integrated"/>
          <remove name="ScriptHandlerFactory"/>
          <remove name="ScriptHandlerFactoryAppServices"/>
          <remove name="ScriptResource"/>
          <add name="ScriptHandlerFactory" verb="*" path="*.asmx" 
                preCondition="integratedMode" 
               type="System.Web.Script.Services.ScriptHandlerFactory, 
                    System.Web.Extensions, Version=3.5.0.0, 
               Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
          <add name="ScriptHandlerFactoryAppServices" verb="*" 
            path="*_AppService.axd" preCondition="integratedMode" 
               type="System.Web.Script.Services.ScriptHandlerFactory, 
                 System.Web.Extensions, Version=3.5.0.0, 
               Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
          <add name="ScriptResource" preCondition="integratedMode" 
            verb="GET,HEAD" path="ScriptResource.axd" 
               type="System.Web.Handlers.ScriptResourceHandler, 
            System.Web.Extensions, Version=3.5.0.0, 
               Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
          <add name="Elmah" verb="POST,GET,HEAD" path="elmah.axd" 
                       preCondition="integratedMode" 
               type="Elmah.ErrorLogPageFactory, Elmah"/>
        </handlers>
      </system.webServer>
    </configuration>

Elmah =(错误记录模块和处理程序)
http://code.google.com/p/elmah/

Elmah = (Error Logging Modules and Handlers)
http://code.google.com/p/elmah/

推荐答案

尝试在 <system.web> 部分的 "httphandlers" 和 "httpmodules" 部分注册模块和处理程序:

Try registering the Modules and Handlers in the sections "httphandlers" and "httpmodules" in the <system.web> section:

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

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

这篇关于Elmah 不使用 asp.net 网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:Elmah 不使用 asp.net 网站

基础教程推荐