Error Handling not Working ASP.NET

R

Rob

Thank you in advance for your help.
I have a response.redirect in my global.asax.vb file to redirect to
err.aspx page, upon an error the redirect works fine but in the
err.aspx all I simply want to do is write out the error for now and do
a bunch of other stuff later, but with the following code, everytime
the whole web app freezes up and just sits there and nothing happens!!
dim objerr As Exception = Server.GetLastError.GetBaseException


Response.Write(objerr.Message.ToString)
Server.ClearError()
is there too much info in the objerror? (I created a sql error on
purpose so all the error should say is Invalid Table name)
 
M

Matt Berther

I'm guessing youre getting stuck in an endless loop, since something in
your error handler is throwing an error.

Try something like this:

Dim objErr as Exception = Server.GetLastError()
if (objErr <> null) then
' You could perform some loop in here to iterate through the
' innerExceptions to get even further into the problem.
Response.Write(objErr.Message)
Server.ClearError()
end if
 
R

Rob

Matt unfortunately this did not work, same result, why would my code
get it stuck in a loop in the first place?
 
M

Matt Berther

Your code could easily get stuck in a loop in the error handler...

ie: any unhandled exception goes to Application_Error, including any
exceptions thrown in Application_Error.

I've been bitten by this a few times. ;) Best thing to do, is check for
nulls where you can and put a try/catch around everything. An error in
the error handler is pretty pointless.
 

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,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top