While I realize this is a simple task and once you see how to do it you will immediately say, I knew that, but for those of you who have not discovered how to detect http 404 errors let me show you.
The following code may be inserted into your Global.asax file.
protected void Application_Error(object sender, EventArgs e)
{
Exception ex = null;
if (HttpContext.Current.Server.GetLastError() != null)
{
ex = HttpContext.Current.Server.GetLastError().GetBaseException();
if (ex.GetType() == typeof(HttpException))
{
HttpException httpException = (HttpException)ex;
if (httpException.GetHttpCode() == 404)
{
Server.Transfer(“~/ErrorHttp404.aspx”);
return;
}
}
}
The above code if placed into you Global.asax file will intercept Http 404 errors and transfer to your page that handles that particular error. You may also check for any other particular http error and transfer to another page if you choose.
You see, it is a simple task, now that you know how.