Application_Error and ASP.NET error screen

  • Thread starter Thread starter A.M
  • Start date Start date
A

A.M

Hi,

I have the following code in Global.asax. Using a breakpoint, i can see that
that all errors are being trapped in Application_Error and the event handler
is being run properly. The problem is still it shows standard ASP.NET error
screen. That means Response.Redirect ("genericerror.htm "); is being
ignored. How can i fix this problem ?

Thanks,
Allan




void Application_Error(Object sender, EventArgs e)

{

Log
(Request.Path,Server.GetLastError().Message,Server.GetLastError().StackTrace
);

Response.Redirect ("genericerror.htm ");
}
 
Hello

better use a
Server.Transfer
You are able to retrieve the exception info there as well!

Regards,

Tom
-----Original Message-----
Hi,

I have the following code in Global.asax. Using a breakpoint, i can see that
that all errors are being trapped in Application_Error and the event handler
is being run properly. The problem is still it shows standard ASP.NET error
screen. That means Response.Redirect
("genericerror.htm "); is being
 
Have you put a custom error handler page in your web.config ?

Try adding the following:

<configuration>
<system.web>
<compilation debug="true"/>
<customErrors mode="On" defaultRedirect="genericerror.htm "/>
</system.web>
</configuration>

Application events are generally not used for specific user things
especially redirects. The reason for this is because the application events
and variables are scoped for the entire application, and not any individual
user.
 
Back
Top