Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Aug 24, 2011 04:03 PM by bebonham
Member
24 Points
13 Posts
Aug 22, 2011 11:01 PM|LINK
if I make a request like http://sever/folder/this_folder_doesnt_exist
I can't seem to trap that error before it goes to the 404 page.
in my class that implements IHttpModule I have
public void Init(HttpApplication context) { context.Error += new EventHandler(context_Error); }
void context_Error(object sender, EventArgs e) {
HttpContext.Current.Server.ClearError();
HttpContext.Current.Response.Write("test");
HttpContext.Current.Response.End();
}
this prints test if I hit a page that is 404
like http://sever/folder/this_folder_doesnt_exist.aspx
but not if it's a "folder in that case I get the default 404 message
http://sever/folder/this_folder_doesnt_exist
How to I trap the 404 for directories like I can for files?
Thank you
Aug 24, 2011 04:03 PM|LINK
I figured that you can call clearError to get futher along the chain of events. I believe PostResolveRequestCache is the last event you will get before you a redirected to a 404.
bebonham
Member
24 Points
13 Posts
Application.Error in an IHttpModule 404 Directory vs File
Aug 22, 2011 11:01 PM|LINK
if I make a request like http://sever/folder/this_folder_doesnt_exist
I can't seem to trap that error before it goes to the 404 page.
in my class that implements IHttpModule I have
public void Init(HttpApplication context)
{
context.Error += new EventHandler(context_Error);
}
void context_Error(object sender, EventArgs e)
{
HttpContext.Current.Server.ClearError();
HttpContext.Current.Response.Write("test");
HttpContext.Current.Response.End();
}
this prints test if I hit a page that is 404
like http://sever/folder/this_folder_doesnt_exist.aspx
but not if it's a "folder in that case I get the default 404 message
http://sever/folder/this_folder_doesnt_exist
How to I trap the 404 for directories like I can for files?
Thank you
bebonham
Member
24 Points
13 Posts
Re: Application.Error in an IHttpModule 404 Directory vs File
Aug 24, 2011 04:03 PM|LINK
I figured that you can call clearError to get futher along the chain of events. I believe PostResolveRequestCache is the last event you will get before you a redirected to a 404.