Application_Error and ASP.NET error screen

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 ");
}
 
T

TE

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
 
G

Greg Huber

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,078
Latest member
MakersCBDBlood

Latest Threads

Top