Error Handling not Working ASP.NET

  • Thread starter Thread starter Rob
  • Start date Start date
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)
 
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
 
Matt unfortunately this did not work, same result, why would my code
get it stuck in a loop in the first place?
 
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.
 
Back
Top