iis 7 でカスタム エラー ハンドラを作成しようとしています。
web.config httpErrors セクション:
<httpErrors>
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" prefixLanguageFilePath="" path="/path/to/handlerwebservice" responseMode="ExecuteURL" />
</httpErrors>
エラーを処理する web.config httpHandler:
<add path="*/path/to/handlerwebservice" verb="GET,HEAD" type="WebServices.Image404Handler, WebServices" validate="false" />
Image404Handler c# コード:
public void ProcessRequest(HttpContext context)
{
string requestpath;
if (context.Request.QueryString.AllKeys.Contains("aspxerrorpath"))
{
requestpath = context.Request.QueryString["aspxerrorpath"];
}
else
{
requestpath = context.Request.Path;
}
// more code not really relevant here
}
404 エラーの原因となったリクエストのパスを取得する方法がわかりません。IIS 6 では、Visual Studio 2008 がこのパスを使用することは、クエリ文字列の aspxerrorpath に追加されます。
リモート デバッグを機能させることができないので、誰かが何をすべきか知っているかどうかここで尋ねています。