Click here to Skip to main content
15,902,764 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, I wrote a code:
protected void Application_Error(Object sender, EventArgs e)
{
  Response.Clear();
  Response.StatusCode = 200;
  Response.Redirect("~/abcd.aspx");
  Response.End;  
}   

I am not redirecting to the custom error page. It shows the server error.
Note: I have to make customerror mode in web.config "Off" and I cannot use server.clearerror() in code.

EDIT ============

Still hasn't been resolved.
Posted
Updated 8-Feb-11 19:45pm
v4
Comments
Sandeep Mewara 14-Jan-11 10:07am    
What server error?

Maybe your path is invalid. I use this technique to make sure the path is going to be correct:

Resolving Paths in a Multi-Folder WebSite[^]



EDIT ==============

@zaidi - Then there's something wrong with the page itself. Try making the page just display something simple like "My Error Page", and see if it gets displayed when you to try to redirect. You might also try commenting out this line:

C#
Response.End();


 
Share this answer
 
v3
Comments
fjdiewornncalwe 14-Jan-11 9:15am    
+5. Love it. I'm on a project right now where your trick will come in handier than the solution we currently use. Thanks.
zaidi.afaque 14-Jan-11 9:20am    
No my path is correct. I've tested it
You can try this code
C#
protected void Application_Error(Object sender, EventArgs e)
{
  Response.Clear();
  Response.StatusCode = 200;
  Response.Redirect("~/error.aspx?Valid=ReqValidExp",false);
  
}   
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900