[asp.net] Elmah가 asp.net 사이트에서 작동하지 않음

내 asp.net 사이트에서 elmah를 사용하려고 시도했지만 http : // localhost : port / elmah.axd 로 이동하려고 할 때마다 리소스를 찾을 수 없음 예외가 발생합니다. 내 web.config는 아래와 같습니다.

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



답변

섹션의 “httphandlers”및 “httpmodules”섹션에서 모듈 및 처리기를 등록 해보십시오 <system.web>.

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


답변

IIS7 배포에서 작동하지 않는 Elmah와 비슷한 문제가 있습니다. system.webAND에 Elmah 모듈 및 핸들러를 등록해야한다는 것을 알았습니다 system.webServer.

<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>
  ...
  <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>
  <handlers>
    ...
    <add name="Elmah" verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
    ...
  </handlers>
<system.webServer>


답변

이것도 필요할 수 있습니다.

<elmah>
    <security allowRemoteAccess="1" />
</elmah>

당신이 얻을 때

403-금지됨 : 액세스가 거부되었습니다. 제공 한 자격 증명을 사용하여이 디렉터리 또는 페이지를 볼 수있는 권한이 없습니다.


답변

NuGet (VS 2013, IIS 8.0)을 사용하여 설치할 때이 줄이 누락되었습니다.

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

그것을 추가하면 404 오류 문제가 해결되었습니다.


답변

오늘 그것을 우회하는 한 가지 방법은 너겟을 사용하는 것입니다.

Visual Studio : 메뉴-> 도구-> 라이브러리 패키지 관리자-> 패키지 관리자 콘솔

install-package elmah

HTH


답변

nuget 패키지는 web.config에 다음과 같은 중요한 줄을 추가하지 않아 403 오류가 발생합니다.

<configuration>
  <elmah>
    <security allowRemoteAccess="1" />
    <errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="~/app_data/elmah" />
  </elmah>
</configuration>

또한 오류 로그에 대한 액세스를 다음과 같이 제한 할 수 있습니다.

<add name="Elmah" verb="POST,GET,HEAD" path="/admin/elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode" />


답변

Areas를 사용하는 경우 appsetting 키 중 하나를 업데이트했는지 확인하십시오.

기본

<add key="elmah.mvc.route" value="elmah" />

관리 영역 인 경우

<add key="elmah.mvc.route" value="admin/elmah" />