2014-07-14 6 views
1

기존 MVC5 프로젝트에 ElmahR을 설치하려고합니다. ElmahR을 설치하기 전에 예외를 처리하기 위해 Elmah와 NLog를 사용하고 있습니다. 난의 Web.config에이어서 ElmahR이 예외를 catch하지 않습니다.

Install-Package ElmahR.Elmah 

패키지

을 nuget 사용 ElmahR 설치이 tutorial에 기초하여, I이 라인 변경 :

<errorPost targetUrl="http://localhost:62335/posterror.axd" sourceId="MyCode" /> 

다음 단계로

<errorPost targetUrl="http://TARGET_DASHBOARD_URL" sourceId="SOURCE_IDENTIFIER_URI_AS_LISTED_IN_DASHBOARD_CONFIG" secret="SECRET_PASSPHRASE_(SPECIFY_JUST_IN_CASE_OF_ENCRYPTED_POST)" /> 

를 I 설치된 대시 보드

Install-Package ElmahR.Modules.Dashboard 
내가 throw new exception("Test ElmahR");하고 실행하여 오류를 생성 HomeController (색인)에서

<application name="WPS" sourceId="MyCode" infoUrl="http://localhost:62335/elmah.axd" testExceptionUrl="http://localhost:62335/elmah.axd/test" /> 

<application name="Sample application" sourceId="SomeCode" infoUrl="http://localhost:12345/elmah.axd" testExceptionUrl="http://localhost:12345/elmah.axd/test" /> 

:

및이 줄을 변경했습니다. 그렇다면 나는 http://locahost:62335/elmahr/dashboard로 가서 아무런 예외도 찾아 볼 수 없지만, 만약 내가 http://localhost:62335/elmah을 보면 "Path '/posterror.axd'Test ElmahR이 발견되지 않았습니다."오류가 발생했습니다. 왜?

전체의 Web.config :

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

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

<?xml version="1.0" encoding="utf-8"?> 
<configuration> 
    <configSections> 
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> 
    <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" /> 
     <section name="errorPost" requirePermission="false" type="Elmah.ErrorLogSectionHandler, Elmah" /> 
    </sectionGroup> 
    <section name="elmahr" type="ElmahR.Core.Config.SectionHandler, ElmahR.Core" /> 
    </configSections> 
    <appSettings> 
    <add key="webpages:Version" value="2.0.0.0" /> 
    <add key="webpages:Enabled" value="false" /> 
    <add key="PreserveLoginUrl" value="true" /> 
    <add key="ClientValidationEnabled" value="true" /> 
    <add key="UnobtrusiveJavaScriptEnabled" value="true" /> 
    <add key="MvcSiteMapProvider_IncludeAssembliesForScan" value="WPSWorklog" /> 
    <add key="MvcSiteMapProvider_UseExternalDIContainer" value="false" /> 
    <add key="MvcSiteMapProvider_ScanAssembliesForSiteMapNodes" value="true" /> 
    <add key="elmah.mvc.disableHandler" value="false" /> 
    <add key="elmah.mvc.disableHandleErrorFilter" value="false" /> 
    <add key="elmah.mvc.requiresAuthentication" value="true" /> 
    <add key="elmah.mvc.IgnoreDefaultRoute" value="false" /> 
    <add key="elmah.mvc.allowedRoles" value="*" /> 
    <add key="elmah.mvc.allowedUsers" value="*" /> 
    <add key="elmah.mvc.route" value="elmah" /> 
    <add key="webpages:Enabled" value="true" /> 
    </appSettings> 
    <system.web> 
    <compilation debug="true" targetFramework="4.5"> 
     <assemblies> 
     <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> 
     </assemblies> 
    </compilation> 
    <customErrors mode="RemoteOnly" defaultRedirect="~/Error"> 
     <error redirect="~/Error/NotFound" statusCode="404" /> 
    </customErrors> 
    <httpRuntime targetFramework="4.5" /> 
    <authentication mode="Windows" /> 
    <authorization> 
     <deny users="?" /> 
    </authorization> 
    <roleManager enabled="true" defaultProvider="AspNetWindowsTokenRoleProvider"> 
     <providers> 
     <clear /> 
     <add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" /> 
     </providers> 
    </roleManager> 
    <pages> 
     <namespaces> 
     <add namespace="System.Web.Helpers" /> 
     <add namespace="System.Web.Mvc" /> 
     <add namespace="System.Web.Mvc.Ajax" /> 
     <add namespace="System.Web.Mvc.Html" /> 
     <add namespace="System.Web.Optimization" /> 
     <add namespace="System.Web.Routing" /> 
     <add namespace="System.Web.WebPages" /> 
     <add namespace="MvcSiteMapProvider.Web.Html" /> 
     <add namespace="MvcSiteMapProvider.Web.Html.Models" /> 
     </namespaces> 
    </pages> 
    <httpModules> 
     <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" /> 
     <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" /> 
     <add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" /> 
     <add name="ErrorPost" type="ElmahR.Elmah.ErrorPostModule, ElmahR.Elmah" /> 
    </httpModules> 
    </system.web> 
    <system.webServer> 
    <validation validateIntegratedModeConfiguration="false" /> 
    <modules runAllManagedModulesForAllRequests="true"> 
     <remove name="UrlRoutingModule-4.0" /> 
     <add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" /> 
     <remove name="BundleModule" /> 
     <add name="BundleModule" type="System.Web.Optimization.BundleModule" /> 
     <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" preCondition="managedHandler" /> 
     <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" preCondition="managedHandler" /> 
     <add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" preCondition="managedHandler" /> 
     <add name="ErrorPost" type="ElmahR.Elmah.ErrorPostModule, ElmahR.Elmah" /> 
     <!-- 
     You may want to enable the following declaration in order 
     to have your dashboard collecting errors happening inside 
     the dashboard itself (ELMAH is needed and must be properly 
     configured). 
     --> 
     <!--<add name="ErrorPost" type="ElmahR.Core.ErrorTrapModule, ElmahR.Core" />--> 
    </modules> 
    <handlers> 
     <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" /> 
     <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" /> 
     <remove name="ExtensionlessUrlHandler-Integrated-4.0" /> 
     <add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" /> 
     <add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" /> 
     <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" /> 
     <add name="PostError" verb="POST" path="PostError.axd" type="ElmahR.Core.PostError, ElmahR.Core" /> 
     <add name="YSOD" verb="GET,HEAD" path="YellowScreenOfDeath.axd" type="ElmahR.Core.YellowScreenOfDeath, ElmahR.Core" /> 
    </handlers> 
    </system.webServer> 
    <runtime> 
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 
     <dependentAssembly> 
     <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" /> 
     <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" /> 
     </dependentAssembly> 
     <dependentAssembly> 
     <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" /> 
     <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" /> 
     </dependentAssembly> 
     <dependentAssembly> 
     <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" /> 
     <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" /> 
     </dependentAssembly> 
     <dependentAssembly> 
     <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" /> 
     <bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" /> 
     </dependentAssembly> 
     <dependentAssembly> 
     <assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35" culture="neutral" /> 
     <bindingRedirect oldVersion="0.0.0.0-1.1.0.0" newVersion="1.1.0.0" /> 
     </dependentAssembly> 
    </assemblyBinding> 
    </runtime> 
    <entityFramework> 
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" /> 
    </entityFramework> 
    <connectionStrings> 
    <add name="WPSWorklogEntities" connectionString="metadata=res://*/Models.WPSWorklog.csdl|res://*/Models.WPSWorklog.ssdl|res://*/Models.WPSWorklog.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=.\SQLEXPRESS;initial catalog=WPSWorklog;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" /> 
    </connectionStrings> 
    <elmah> 
    <!--<errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="~/App_Data/XMLLog" />--> 
    <errorFilter> 
     <test> 
     <and> 
      <equal binding="HttpStatusCode" value="404" type="Int32" /> 
      <regex binding="Context.Request.ServerVariables['URL']" pattern="/favicon\.ico(\z|\?)" /> 
     </and> 
     </test> 
    </errorFilter> 
    <security allowRemoteAccess="false" /> 
    <errorLog type="Elmah.MemoryErrorLog, Elmah" /> 
    <errorPost targetUrl="http://localhost:62335/posterror.axd" sourceId="MyCode" /> 
    </elmah> 
    <elmahr> 
    <application name="WPS" sourceId="MyCode" infoUrl="http://localhost:62335/elmah.axd" testExceptionUrl="http://localhost:62335/elmah.axd/test" /> 
    </elmahr> 
</configuration> 

UPDATE

이 @Wasp 제안, 나는이 system.websystem.webServer에 ELMAH 모듈 및 처리기를 등록하지만 하나는 여전히 문제가 해결되지

+0

어떤 서버를 사용하고 있습니까? VS에서 IIS 또는 Web Dev 서버? – Wasp

+0

@Wasp 늦게 답변을 드려 죄송합니다. VS에서 IIS 또는 Web Dev 서버를 사용하여 실행되는지 여부는 알 수 없습니다. 그걸 어떻게 알아? 웹용 Visual Studio Express 2013 - 새 프로젝트 - ASP.NET 웹 응용 프로그램 - MVC를 사용하여 만든 기존 MVC5에 ElmahR을 설치했습니다. – Willy

+0

프로젝트의 웹 속성 탭에서 확인할 수 있습니다. – Wasp

답변

0

IIS (Full 또는 Express)를 사용하지 않는 경우에 system.web/httpHandlers 섹션이 표시되지 않기 때문에 문제가 발생할 수 있습니다.은 누락 된 posterror.axd 끝점을 선언 할 곳입니다. 끝점은 system.webserver/handlers 섹션에 있지만 IIS가 필요합니다. 그걸 확인 했니?

+0

흠 .. 어떻게 확인해야할지 모르겠다 고요? 비교를 위해 VS 2012 Express에서 새로운 MVC4 프로젝트를 만들고 같은 방식으로 수행하고, 대시 보드를 보면 오류가 표시됩니다. web.config에는 system.web/httpHandlers가 없지만 예외를 잡습니다. 웹용 VS Express 2013과의 호환성 문제가 있습니까? – Willy

+0

특정 호환성 문제는 잘 모르겠지만 이러한 특정 시나리오에서 어떤 일이 발생하는지, IIS를 사용하는지 여부는 확실하지 않습니다. VS 2013 프로젝트에'system.web/httpHandlers'를 추가하고 도움이되는지 확인하십시오. 당신은 주위에있는 문서를 확인하고'system.webserver/handler '에 가지고있는 것을 옮겨 놓음으로써 그 핸들러를 설정하는 방법을 알아낼 수있을 것이다. – Wasp