당신은 당신의 Global.asax.cs에 같은 같은 ELMAH과 함께 일을 필터링 할 수 있습니다
//ELMAH Filtering
protected void ErrorLog_Filtering(object sender, ExceptionFilterEventArgs e)
{
FilterError404(e);
}
protected void ErrorMail_Filtering(object sender, ExceptionFilterEventArgs e)
{
FilterError404(e);
}
//Dimiss 404 errors for ELMAH
private void FilterError404(ExceptionFilterEventArgs e)
{
if (e.Exception.GetBaseException() is HttpException)
{
HttpException ex = (HttpException)e.Exception.GetBaseException();
if (ex.GetHttpCode() == 404)
{
e.Dismiss();
}
}
}
그래서 필터링의 어떤 부분에 FilterError404에 대한 호출을 추가합니다. 위의 예제는 오류 로그와 이메일 모두에 대해 필터 404를 갖습니다. 또한 체크 아웃 : http://code.google.com/p/elmah/wiki/ErrorFiltering
를 링크에 설명 된대로는 소스에 의해 필터링을 수행 할 수 있습니다
<elmah>
...
<errorFilter>
<test>
<and>
<equal binding="HttpStatusCode" value="404" type="Int32" />
<regex binding="FilterSourceType.Name" pattern="mail" />
</and>
</test>
</errorFilter>
</elmah>
확인 Web.config의 : 참고로
<?xml version="1.0" encoding="UTF-8"?>
<!--
Note: As an alternative to hand editing this file you can use the
web admin tool to configure settings for your application. Use
the Website->Asp.Net Configuration option in Visual Studio.
A full list of settings and comments can be found in
machine.config.comments usually located in
\Windows\Microsoft.Net\Framework\v2.x\Config
-->
<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>
<appSettings />
<!-- ELMAH: Configuration -->
<elmah>
<security allowRemoteAccess="1" />
<errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="Elmah.Sql" />
<errorMail defaultCredentials="true" from="[email protected]" to="[email protected], [email protected]" subject="Error (STAGING): {0}" async="true" smtpPort="25" smtpServer="192.168.1.1" userName="smtpUserName" password="smtpPassword" />
</elmah>
<connectionStrings>
<add name="Elmah.Sql" connectionString="Data Source=192.168.1.1;database=DBName;integrated security=false;User ID=MyUserName;Password=MyPassword" />
</connectionStrings>
<system.net>
<mailSettings>
<smtp deliveryMethod="Network" from="[email protected]">
<network defaultCredentials="true" host="192.168.1.1" port="25" userName="smtpUserName" password="smtpPassword" />
</smtp>
<!-- Use this setting for development
<smtp deliveryMethod="SpecifiedPickupDirectory">
<specifiedPickupDirectory pickupDirectoryLocation="C:\Temp" />
</smtp>
-->
</mailSettings>
</system.net>
<system.web>
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only
during development.
-->
<compilation debug="true">
<assemblies>
...........................
</assemblies>
</compilation>
.......................
<!--
The <customErrors> section enables configuration
of what to do if/when an unhandled error occurs
during the execution of a request. Specifically,
it enables developers to configure html error pages
to be displayed in place of a error stack trace.
-->
<customErrors mode="RemoteOnly" defaultRedirect="~/Home/MyErrorPage" />
.............................
<httpHandlers>
..............................
<!--ELMAH-->
<add verb="POST,GET,HEAD" path="/MyErrorPage/elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
</httpHandlers>
<httpModules>
........................
<!-- ELMAH: Logging module -->
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" />
<add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" />
</httpModules>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true">
.............................
<!-- ELMAH-->
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" />
<add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" />
<add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" />
</modules>
<handlers>
..............
<!--ELMAH-->
<add name="Elmah" verb="POST,GET,HEAD" path="/MyErrorPage/elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
</handlers>
</system.webServer>
..................
</configuration>
: 설명으로 NuGET 패키지도 가능 Scott Hanselman : http://www.hanselman.com/blog/NuGetPackageOfTheWeek7ELMAHErrorLoggingModulesAndHandlersWithSQLServerCompact.aspx
누락 된 URL의 홈 페이지로 사용자를 리디렉션하는 것은 티 - 패턴과 피해야합니다. 그럴 가능성이있는 것은 사용자를 혼란스럽게하는 것입니다. "x 링크를 클릭하면 왜 홈 페이지로 갔습니까?" 대신 문제를 간단하고 명확하게 설명하는 헌신적 인 404 페이지가 있어야하며 사용자가 찾고있는 페이지 (예 : 사이트 맵)를 찾는 데 이상적입니다. 또한 처음에 오류를 피하기 위해 끊어진 링크 등이 있는지 확인하기 위해 기록 된 404 오류 (또는 웹 마스터 도구)를 정기적으로 검토하는 것이 좋습니다. – pwdst