Global_Error in Web applications?

I am reading about Error Events in ASP.NET Web applications in preparation for a Microsoft certification test. The book mentions that there are three error events in a Web application, a Page_Error, Global_Error, and Application_Error. I can find the Application_Error event and the Page_Error event, but I see no Global_Error event. Is this just a mistake in the book?
PLavelleAsked:
Who is Participating?
 
gregoryyoungConnect With a Mentor Commented:
I show how to handle this error here http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/ASP.NET/Q_20975926.html

I can assure you it handles it .
0
 
GoodJunCommented:
Global_Error is the same as Application_Error. You can change the name. The vs.net only use Application_Error in the IDE, you can type over use Global_Error
0
 
PLavelleAuthor Commented:
If i rename it, I can't get the Global_Error event to fire, but I can get the Application_Event to fire before it was renamed
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
GoodJunCommented:
There is not much document on the Global_Error stuff. Forget my last comments from memory. Here are some related copied from link:
http://www.dotnetjunkies.com/Article/4073C212-9B02-4229-89F5-92F4F2EDBAD4.dcik

Every Web Form and Web Service project has a global.asax unit. Double clicking that item in the solution explorer will reveal a design surface just like a component. After clicking the link to the code you see the global class, it descends from the System.web.HttpApplication. This HTTPapplication-object will receive all requests and assemble the response. Requests will be passed one by one. The processing of the request is done in a number of steps. After each step an event is fired. In the global class generated by VS.NET you will see a number of methods whose name starts with Application, they respond to events in the application as a whole. The HTTPApplication class has a large array of event-handlers, these events are fired by the actual object which is handling the request. ASP.NET can load multiple global objects in one application; a request is always processed by just one of the global objects. To program the HTTPapplication you write code in the generated Application methods. Your methods can subscribe to the global events, provided they have the right signature.

0
 
gregoryyoungCommented:
They are different despite what is beig said above ... I will explain the difference

Page_Error is generated by the base of the page

Application_Error is generated by a runtime generated subcass of httpapplication (global.asax)
Global Error is generated via the Application object (which HttpApplication is derived from)

Although the other two are similar they are different in signature, where they are thrown from, and the fact that the global error is 1 delegate for everything where as the application error is only for exceptions within that instance of the httpapplication (there is more than one of these in an asp.net application) ...

public event EventHandler Error; (raises Arument of EventArgs)
public static event ThreadExceptionEventHandler ThreadException; (raises argument ThreadExceptionEventArgs)

the global exception also includes the original exception in the event args where as the application exception makes you cal getlasterror
0
 
EBatistaCommented:
i have made a search in yahoo and google, not much usefull info founded, just this from a forum elsewhere:

http://staff.develop.com/candera/weblog2/CommentView.aspx?guid=c5bc0e98-c906-47e1-a8a5-63641d43729e

regards
0
 
gregoryyoungCommented:
Do you need further information than what I gave on global errors ?
0
 
PLavelleAuthor Commented:
Yeah I guess I'm still having trouble really understanding what they are both used for.
0
 
gregoryyoungCommented:
ok ...

Application_error is per httpapplication object in scope .. Also you have to call server.getlasterror() here.

the globalerror aka threaderror is on the application object and is global in scope. It has many uses. One of the big ones is that I can write exception handling classes that I bind to it which work in either a forms app or a webforms app. Also you are given the exception in your event args. Also if there are errors within my domain that are not part of my http application I will receive those errors (example being if I start up a thread)
0
 
PLavelleAuthor Commented:
Can you post some code that will cause the Global error event to fire and not the Application event?
0
 
gregoryyoungCommented:
start up a thread that is outside of the httpapplication and let an unhandled exception occur.
0
 
gregoryyoungCommented:
dim t as new Thread(addressof CauseError)
t.Start()


public sub CauseError()
Thread.Sleep(100000)
throw new system.exception("dying")
end sub

I believe the httpapplication will not pick this up.
0
 
PLavelleAuthor Commented:
nothing seems to pick it up. I just get a 'Request Details' page.
0
 
PLavelleAuthor Commented:
Actually, when the exception occurs it gives me an Unhandled Exception dialog.
0
 
gregoryyoungCommented:
do you have something handling the global error area ? the threadexception event ?
0
 
gregoryyoungCommented:
is there further help needed here ?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.