Getting more detailed errors

D

darrel

I have a question below about an error I am getting:

Exception has been thrown by the target of an invocation.

Is there anyway to get asp.net to give me more details than the above? My
catch statement is as such:

Catch exc As system.Exception
div_updateLog.Visible = true
lbl_updateLog.text = exc.Message
End Try

-Darrel
 
A

Alan Ferrandiz Langley [MCT]

In the applications I develop I catch any exception in the Global_Error event handler in the Global.asax file. Basically I use

Request.FilePath to get the name of the file where the error was thrown
Server.GetLastError.InnerException this is actually the detailed exception you might be looking for .. i find this property extremely useful
Server.GetLastError.StackTrace you get the sequence of procedures executed that lead to the exception
Server.MachineName the server name where the exception ocurred, you can skip this but in my case i have both a development and production server and this property allows me to tell if I caused the exception when developing or the exception was thrown by a user
Request.ServerVariables("HTTP_USER_AGENT") the client browser information ... very useful if you want to create statistics about who mess with your app
Request.ServerVariables("REMOTE_ADDR") the client IP adress where the error ocurred... if you are in an intranet it is useful but if you app is public then you probably are behind a firewall and you will get the firewall IP adress.

I create a report email for every exception. Play around with them and try several ways to catch and handle exceptions

Hope this helps
Alan Ferrandiz Langley
geekswithblogs.com/aferrandiz
 
D

darrel

In the applications I develop I catch any exception in the Global_Error
event handler in the Global.asax file. Basically I use

Alan:

That's a very thorough list. Thank you!

-Darrel
 

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

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top