Application_Error does not fire

A

Andy G

For testing purposes I put a
Throw New Exception("Something didn't work right.") on the click of a button
on a page. In the application_error section of my application I have a

Response.Redirect("error.htm")

Later I will had error logging and email functionallity to this but in the
mean time I just need the application to redirect to this error.htm page.
This works perfectly fine in another application I have. It seems like the
Applicaiton_Error is not getting called during an application error.



Thanks
 
A

albert braun

One thought: are you sure the button handler code is being called and
actually throwing the exception?

What happens after you click the button? (e.g. Do you get a default
error page?)

- albert
 
A

Andy G

I get the defalut error page that says "Something didn't work right" on the
top. I've put a break point on the Sub Application_Error and nothing ever
happens.
 
A

albert braun

more questions:

does the "Something didn't work right" error message in that page
something like this:
Line 4:
Line 5: Protected Sub Button1_Click(ByVal sender As Object, ByVal
e As System.EventArgs) Handles Button1.Click
Line 6: Throw New Exception("generated by my VB Test page.")
Line 7:
Line 8: End Sub

i mean, are you seeing the very same exception you intentionally threw
in the button click handler? or is there something else wrong?

is your Application_Error method defined in the Global.asax file (or if
using codebehind, the Global.asax.vb file)?
 
A

Andy G

The code is below for both locations. I'm starting to think it has
something to do with settings in IIS or on the server.


Code that throws the error.
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Throw New Exception("Something didn't work right.")

End Sub


Code in the Application_Error event that resides in my Global.asax.vb

Server.ClearError()

Response.Redirect("error.htm")
 
Joined
Jul 10, 2006
Messages
1
Reaction score
0
Application_Error not firing

Hi Andy G.
Did you ever resolve your problem of Application_Error not firing. I have the same problem now, even on brand new applications that I create.
 

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,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top