?
Solved

Global_Error in Web applications?

Posted on 2004-04-28
18
Medium Priority
?
756 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

 
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
 

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 2000 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

How To Install Bash on Windows 10

Windows’ budding partnership with Canonical has certainly led to some great improvements. One of them being the ability to use Bash on your Windows machine without third party applications! This might be one of the greatest things a cloud engineer in a Windows environment can do!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

771 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