作成したカスタム エラー ハンドラに問題があります。である必要がありますが、のタグHttpModule
に追加すると開始されません。web.config
system.webServer/modules
これは私のweb.config
セクションです:
<system.webServer>
<modules>
<add name="AspExceptionHandler"
type="Company.Exceptions.AspExceptionHandler, Company.Exceptions"
preCondition="managedHandler" />
</modules>
</system.webServer>
これは私のコードですHttpModule
:
using System;
using System.Web;
using Company.Settings;
using System.Configuration;
namespace Company.Exceptions
{
public class AspExceptionHandler : IHttpModule
{
public void Dispose() { }
public void Init(HttpApplication application)
{
application.Error += new EventHandler(ErrorHandler);
}
private void ErrorHandler(object sender, EventArgs e)
{
HttpApplication application = (HttpApplication)sender;
HttpContext currentContext = application.Context;
// Gather information5
Exception currentException = application.Server.GetLastError();
String errorPage = "http://www.mycompaniesmainsite.com/error.html";
HttpException httpException = currentException as HttpException;
if (httpException == null || httpException.GetHttpCode() != 404)
{
currentContext.Server.Transfer(errorPage, true);
}
else
{
application.Response.Status = "404 Not Found";
application.Response.StatusCode = 404;
application.Response.StatusDescription = "Not Found";
currentContext.Server.Transfer(errorPage, true);
}
}
}
}
誰かが私が間違っていることと、IIS 7 統合マネージド パイプライン モードがどのように機能するかを説明してもらえますか? 私が見つけた答えのほとんどは、HttpModules
IIS 6 の構成に関するものだったからです。