Solved

Global_Error in Web applications?

Posted on 2004-04-28
18
735 Views
Last Modified: 2012-08-14
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?
0
Comment
Question by:PLavelle
  • 8
  • 5
  • 2
  • +1
18 Comments
 
LVL 10

Expert Comment

by:GoodJun
ID: 10942454
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
 

Author Comment

by:PLavelle
ID: 10942533
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
 
LVL 10

Expert Comment

by:GoodJun
ID: 10942579
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
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 10942705
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
 
LVL 10

Expert Comment

by:EBatista
ID: 10943130
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
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 11002225
Do you need further information than what I gave on global errors ?
0
 

Author Comment

by:PLavelle
ID: 11004748
Yeah I guess I'm still having trouble really understanding what they are both used for.
0
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 11006238
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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

Author Comment

by:PLavelle
ID: 11006629
Can you post some code that will cause the Global error event to fire and not the Application event?
0
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 11006675
start up a thread that is outside of the httpapplication and let an unhandled exception occur.
0
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 11006733
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
 

Author Comment

by:PLavelle
ID: 11006841
nothing seems to pick it up. I just get a 'Request Details' page.
0
 

Author Comment

by:PLavelle
ID: 11006888
Actually, when the exception occurs it gives me an Unhandled Exception dialog.
0
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 11006949
do you have something handling the global error area ? the threadexception event ?
0
 
LVL 37

Accepted Solution

by:
gregoryyoung earned 500 total points
ID: 11007113
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
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 11043865
is there further help needed here ?
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now