I am trying to create a custom error handler in iis 7.
web.config httpErrors section:
<httpErrors>
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" prefixLanguageFilePath="" path="/path/to/handlerwebservice" responseMode="ExecuteURL" />
</httpErrors>
web.config httpHandler to handle error:
<add path="*/path/to/handlerwebservice" verb="GET,HEAD" type="WebServices.Image404Handler, WebServices" validate="false" />
Image404Handler c# code:
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
}
I can't figure out how to get the path of the request that caused the 404 error to trigger. In IIS 6, that Visual Studio 2008 uses this path is added to aspxerrorpath in the querystring.
I can't get remote debugging to work so I am asking here if someone knows what to do.