473,396 Members | 2,004 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How are Application_Start, etc., called?

How do the Application methods like

protected void Application_Start

get called? They aren't base class overrides and they aren't
implementing interface methods. What mechanism does the system use to
call them?

In a Web form, a similar handler like

private void Page_Load

gets called by virtue of the fact that the following line appears later
on in the page, in the OnInit override:

this.Load += new System.EventHandler(this.Page_Load);

But there isn't anything comparable in Global.asax.
Aug 4 '06 #1
6 3032
They are events and they are wired up internally in ASP.NET
when the request is processed, session starts, or application
starts.

--
Robbe Morris - 2004-2006 Microsoft MVP C#
Microsoft .NET Search Engine Scoring Analysis
How does your site rate?
http://www.topichound.com


"Harlan Messinger" <hm*******************@comcast.netwrote in message
news:4j************@individual.net...
How do the Application methods like

protected void Application_Start

get called? They aren't base class overrides and they aren't implementing
interface methods. What mechanism does the system use to call them?

In a Web form, a similar handler like

private void Page_Load

gets called by virtue of the fact that the following line appears later on
in the page, in the OnInit override:

this.Load += new System.EventHandler(this.Page_Load);

But there isn't anything comparable in Global.asax.

Aug 4 '06 #2
Does it matterIs it not enough to know that they are fired?

"Harlan Messinger" wrote:
How do the Application methods like

protected void Application_Start

get called? They aren't base class overrides and they aren't
implementing interface methods. What mechanism does the system use to
call them?

In a Web form, a similar handler like

private void Page_Load

gets called by virtue of the fact that the following line appears later
on in the page, in the OnInit override:

this.Load += new System.EventHandler(this.Page_Load);

But there isn't anything comparable in Global.asax.
Aug 4 '06 #3
Hi,

Could you avoid top posting? It makes the posts very difficult to read.
clickon wrote:
Does it matterIs it not enough to know that they are fired?
It does matter if you want to hook your own event handlers, for example.
It also matters if you want to have a deep understanding of how ASP.NET
works.

HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Aug 4 '06 #4
clickon wrote:
"Harlan Messinger" wrote:
>How do the Application methods like

protected void Application_Start

get called? They aren't base class overrides and they aren't
implementing interface methods. What mechanism does the system use to
call them?

In a Web form, a similar handler like

private void Page_Load

gets called by virtue of the fact that the following line appears later
on in the page, in the OnInit override:

this.Load += new System.EventHandler(this.Page_Load);

But there isn't anything comparable in Global.asax.
Does it matterIs it not enough to know that they are fired?
In case you're not aware of it, there are people in this world who are
curious about how things work. You should be thankful for that. Think
how the world would be otherwise.
Aug 4 '06 #5
Hi,

Harlan Messinger wrote:
How do the Application methods like

protected void Application_Start

get called? They aren't base class overrides and they aren't
implementing interface methods. What mechanism does the system use to
call them?

In a Web form, a similar handler like

private void Page_Load

gets called by virtue of the fact that the following line appears later
on in the page, in the OnInit override:

this.Load += new System.EventHandler(this.Page_Load);

But there isn't anything comparable in Global.asax.
The Global.asax only defines the event handlers' body, not how they are
fired. The method Application_Start is the equivalent of the Page_Load
in the line you wrote here above. The "hook" to the "Start" event (which
is the equivalent of the "Load" event in the line here above) is not
defined in Global.asax. The methods are called at various moments by the
different modules involved in processing the request.

There is an interesting post about this at
http://www.dotnet247.com/247referenc.../12/62243.aspx

HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Aug 4 '06 #6
Laurent Bugnion wrote:
Hi,

Harlan Messinger wrote:
>How do the Application methods like

protected void Application_Start

get called? They aren't base class overrides and they aren't
implementing interface methods. What mechanism does the system use to
call them?

In a Web form, a similar handler like

private void Page_Load

gets called by virtue of the fact that the following line appears
later on in the page, in the OnInit override:

this.Load += new System.EventHandler(this.Page_Load);

But there isn't anything comparable in Global.asax.

The Global.asax only defines the event handlers' body, not how they are
fired. The method Application_Start is the equivalent of the Page_Load
in the line you wrote here above. The "hook" to the "Start" event (which
is the equivalent of the "Load" event in the line here above) is not
defined in Global.asax.
Right, that's the part that I wasn't expecting.
The methods are called at various moments by the
different modules involved in processing the request.
I was just curious *how*, since there isn't an interface or base class
through which they could be doing that. It's occurring to me that it
must be through reflection, which seems sloppy and unnecessary, but
maybe the aspnet really handles the whole creation of the application
class object at that low level.
There is an interesting post about this at
http://www.dotnet247.com/247referenc.../12/62243.aspx
Thanks for that interesting overview.
Aug 4 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Halcyon Woodward | last post by:
I have an odd problem... We have a small development team (three coders) working on the same project (a C# web application). Each coder has a unique 'sandbox' site on a shared Windows 2003...
4
by: Max | last post by:
I've noticed some procedures don't run in the global.asax when you'd expect them to. I've rebuilt and set break points, but Application_Start just isn't firing today. Is there some configuration...
1
by: jonathan zheng | last post by:
I have built a web application and I put some code in the Application_Start, but what surprised me is that these codes are called more than one time. Actually when a new request is begin, these codes...
0
by: SeanGallavan | last post by:
Our Environment: Two network load balanced (using Microsoft NLB software) webservers with session maintained in a SQL Server database. NLB is configured with no affinity settings and two...
8
by: bryan | last post by:
Is there any way I can get the application path (the one returned by Request.ApplicationPath) in the Application_Start method in Global.asax? Request is not valid there. On a related note, is there...
4
by: NoNickname | last post by:
Hi, I need to get a string from a COM component at application start. (It's a Long Story and I cannot change this fact.) In ASP.NET 1.1, I simply called this COM component in Global.asax.cs...
12
by: Thomas H. Lanier | last post by:
In ASP.NET is there a way to run some code when IIS first loads? The Application_Start event is called when the first resource (such as a page) in an ASP.NET application is requested. I need...
0
by: Flemming | last post by:
I'm using Remoting which is applied inside application_start. In ASP.NET 2.0 application_start seems to be called when shifting domains in the same application - i.e. http://mydomain.dk...
0
by: =?Utf-8?B?amNoYW4=?= | last post by:
Hi, I have a webservice application which was developed in vs2003. After I rewrite it in vs2005, the Application_Start behaves differently. The Application_Start keeps getting triggered when...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.