Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Global_Error in Web applications?

Posted on 2004-04-28
18
Medium Priority
?
759 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
NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Flash (http://en.wikipedia.org/wiki/Adobe_Flash) has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

618 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