473,574 Members | 2,636 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Life cycle of ASP .NET Application

jim
Hi All,

I like to know the life cycle of an ASP .NET Application( incudieng server
application, such as .NET Web Service). That means from initialization to
fully running and how to reboot it or shut it down. Including how to
establish the running environment( current working folder, ...etc) for each
ASP .NET application.

Because in my ASP .NET application, there are a lot of modules. Some were
developed by using VC#, others using VC++ .net. In these module, it may using
LoadLibrary to load third party library. So, I need to know the current
environment of my ASP .NET application. And also, there are some
initialization task will be done in Application_Sta rt( which is
Application-level ), So I also need to know the full life cycle of my ASP
..NET application to make sure that it can be initialized, unintialized, or
reinitialized properly.

Anybody have any advice would be great appreciated.

Thanks a lot,

Jim
Nov 19 '05 #1
6 2628
Check out this sample chapter from Programming ASP.NET book by Dino,
http://www.microsoft.com/mspress/boo...pchap/6667.asp

--
-Saravana
http://dotnetjunkies.com/WebLog/saravana/
www.ExtremeExperts.com

"jim" <ji*@discussion s.microsoft.com > wrote in message
news:66******** *************** ***********@mic rosoft.com...
Hi All,

I like to know the life cycle of an ASP .NET Application( incudieng server
application, such as .NET Web Service). That means from initialization to
fully running and how to reboot it or shut it down. Including how to
establish the running environment( current working folder, ...etc) for each ASP .NET application.

Because in my ASP .NET application, there are a lot of modules. Some were
developed by using VC#, others using VC++ .net. In these module, it may using LoadLibrary to load third party library. So, I need to know the current
environment of my ASP .NET application. And also, there are some
initialization task will be done in Application_Sta rt( which is
Application-level ), So I also need to know the full life cycle of my ASP
.NET application to make sure that it can be initialized, unintialized, or
reinitialized properly.

Anybody have any advice would be great appreciated.

Thanks a lot,

Jim

Nov 19 '05 #2
jim
Thank you -- Saravana,

I like to know the whole life cycle of ASP .NET application, not just a
specific web pages. For example, how IIS lanching the ASP .NET application,
which the instance of Global class will be created and the related
Application_Sta rt method will be invoked. Actually, that means the life cycle
of the instance of Global class in ASP .NET application. When it will be
created and when it will be destroied. Who are responsible to create it?

Thanks a lot,

Jim
"Saravana" wrote:
Check out this sample chapter from Programming ASP.NET book by Dino,
http://www.microsoft.com/mspress/boo...pchap/6667.asp

--
-Saravana
http://dotnetjunkies.com/WebLog/saravana/
www.ExtremeExperts.com

"jim" <ji*@discussion s.microsoft.com > wrote in message
news:66******** *************** ***********@mic rosoft.com...
Hi All,

I like to know the life cycle of an ASP .NET Application( incudieng server
application, such as .NET Web Service). That means from initialization to
fully running and how to reboot it or shut it down. Including how to
establish the running environment( current working folder, ...etc) for

each
ASP .NET application.

Because in my ASP .NET application, there are a lot of modules. Some were
developed by using VC#, others using VC++ .net. In these module, it may

using
LoadLibrary to load third party library. So, I need to know the current
environment of my ASP .NET application. And also, there are some
initialization task will be done in Application_Sta rt( which is
Application-level ), So I also need to know the full life cycle of my ASP
.NET application to make sure that it can be initialized, unintialized, or
reinitialized properly.

Anybody have any advice would be great appreciated.

Thanks a lot,

Jim


Nov 19 '05 #3
An ASP.NET Framework application is created the first time
a request is made to the server; before that, no ASP.NET code
executes.

When the first request is made, a pool of HttpApplication
instances is created and the Application_Sta rt event is raised.

The HttpApplication instances process this and subsequent requests,
until the last instance exits and the Application_End event is raised.

Usually that only happens when you use iisreset.exe to force
an IIS stop/start, when you shutdown the server, or when a
fatal error which stops IIS occurs.

The life cycle of a Web application would consist of these events:

Application_Sta rt is raised only once during an application's lifetime,
on the first instance of HttpApplication . An application starts the first
time it is run by IIS for the first user. In your event handler you can
initialize a state that is shared by the entire application.

Session_Start is raised at the start of each session if you
enable Sessions. Here you can initialize session variables.

Application_Beg inRequest is raised at the start of an individual request.
Normally you do your request processing in the Page class.

Application_End Request is raised at the end of a request.

An application executes events that are handled by modules
or user code defined in the global.asax file in the following sequence:

BeginRequest
AuthenticateReq uest
AuthorizeReques t
ResolveRequestC ache
[A handler (a page corresponding to the request URL) is created at this
point.]
AcquireRequestS tate
PreRequestHandl erExecute
[The handler is executed.]
PostRequestHand lerExecute
ReleaseRequestS tate
[Response filters, if any, filter the output.]
UpdateRequestCa che
EndRequest

Session_End is raised at the end of each session,
if you have enabled Sessions.

Application_End is raised at the end of an application's lifetime,
when the last instance of HttpApplication shuts down.

Hope this helps...

Juan T. Llibre
ASP.NET MVP
===========
"jim" <ji*@discussion s.microsoft.com > wrote in message
news:66******** *************** ***********@mic rosoft.com...
Hi All,

I like to know the life cycle of an ASP .NET Application( incudieng server
application, such as .NET Web Service). That means from initialization to
fully running and how to reboot it or shut it down. Including how to
establish the running environment( current working folder, ...etc) for
each
ASP .NET application.

Because in my ASP .NET application, there are a lot of modules. Some were
developed by using VC#, others using VC++ .net. In these module, it may
using
LoadLibrary to load third party library. So, I need to know the current
environment of my ASP .NET application. And also, there are some
initialization task will be done in Application_Sta rt( which is
Application-level ), So I also need to know the full life cycle of my ASP
.NET application to make sure that it can be initialized, unintialized, or
reinitialized properly.

Anybody have any advice would be great appreciated.

Thanks a lot,

Jim


Nov 19 '05 #4
instances of Global application are stored in a pool. they are created on
page references. the first instance is created on the first page request to
the site, which fire the Start event. additional instances are only created
when more than 1 page request is in use. when these instaces are created, no
event is fired. while the pool may get pruned, the life of the global
application is from the 1st page request until the application domain is
unloaded. the domain will be unloaded if the timeout occurs (to long between
page requests), a recycle event - your app is using too many resources, a
file change or a iis reset.

-- bruce (sqlwork.com)

"jim" <ji*@discussion s.microsoft.com > wrote in message
news:D5******** *************** ***********@mic rosoft.com...
| Thank you -- Saravana,
|
| I like to know the whole life cycle of ASP .NET application, not just a
| specific web pages. For example, how IIS lanching the ASP .NET
application,
| which the instance of Global class will be created and the related
| Application_Sta rt method will be invoked. Actually, that means the life
cycle
| of the instance of Global class in ASP .NET application. When it will be
| created and when it will be destroied. Who are responsible to create it?
|
| Thanks a lot,
|
| Jim
|
|
| "Saravana" wrote:
|
| > Check out this sample chapter from Programming ASP.NET book by Dino,
| > http://www.microsoft.com/mspress/boo...pchap/6667.asp
| >
| > --
| > -Saravana
| > http://dotnetjunkies.com/WebLog/saravana/
| > www.ExtremeExperts.com
| >
| >
| >
| > "jim" <ji*@discussion s.microsoft.com > wrote in message
| > news:66******** *************** ***********@mic rosoft.com...
| > > Hi All,
| > >
| > > I like to know the life cycle of an ASP .NET Application( incudieng
server
| > > application, such as .NET Web Service). That means from initialization
to
| > > fully running and how to reboot it or shut it down. Including how to
| > > establish the running environment( current working folder, ...etc) for
| > each
| > > ASP .NET application.
| > >
| > > Because in my ASP .NET application, there are a lot of modules. Some
were
| > > developed by using VC#, others using VC++ .net. In these module, it
may
| > using
| > > LoadLibrary to load third party library. So, I need to know the
current
| > > environment of my ASP .NET application. And also, there are some
| > > initialization task will be done in Application_Sta rt( which is
| > > Application-level ), So I also need to know the full life cycle of my
ASP
| > > .NET application to make sure that it can be initialized,
unintialized, or
| > > reinitialized properly.
| > >
| > > Anybody have any advice would be great appreciated.
| > >
| > > Thanks a lot,
| > >
| > > Jim
| > >
| > >
| >
| >
| >
Nov 19 '05 #5
jim
Thanks for your help --- Juan,

I have another question: How can I access the Instance of Global which is
inherite from httpApplication class in my ASP.NET page code?

Thanks in advance.
Jim
"Juan T. Llibre" wrote:
An ASP.NET Framework application is created the first time
a request is made to the server; before that, no ASP.NET code
executes.

When the first request is made, a pool of HttpApplication
instances is created and the Application_Sta rt event is raised.

The HttpApplication instances process this and subsequent requests,
until the last instance exits and the Application_End event is raised.

Usually that only happens when you use iisreset.exe to force
an IIS stop/start, when you shutdown the server, or when a
fatal error which stops IIS occurs.

The life cycle of a Web application would consist of these events:

Application_Sta rt is raised only once during an application's lifetime,
on the first instance of HttpApplication . An application starts the first
time it is run by IIS for the first user. In your event handler you can
initialize a state that is shared by the entire application.

Session_Start is raised at the start of each session if you
enable Sessions. Here you can initialize session variables.

Application_Beg inRequest is raised at the start of an individual request.
Normally you do your request processing in the Page class.

Application_End Request is raised at the end of a request.

An application executes events that are handled by modules
or user code defined in the global.asax file in the following sequence:

BeginRequest
AuthenticateReq uest
AuthorizeReques t
ResolveRequestC ache
[A handler (a page corresponding to the request URL) is created at this
point.]
AcquireRequestS tate
PreRequestHandl erExecute
[The handler is executed.]
PostRequestHand lerExecute
ReleaseRequestS tate
[Response filters, if any, filter the output.]
UpdateRequestCa che
EndRequest

Session_End is raised at the end of each session,
if you have enabled Sessions.

Application_End is raised at the end of an application's lifetime,
when the last instance of HttpApplication shuts down.

Hope this helps...

Juan T. Llibre
ASP.NET MVP
===========
"jim" <ji*@discussion s.microsoft.com > wrote in message
news:66******** *************** ***********@mic rosoft.com...
Hi All,

I like to know the life cycle of an ASP .NET Application( incudieng server
application, such as .NET Web Service). That means from initialization to
fully running and how to reboot it or shut it down. Including how to
establish the running environment( current working folder, ...etc) for
each
ASP .NET application.

Because in my ASP .NET application, there are a lot of modules. Some were
developed by using VC#, others using VC++ .net. In these module, it may
using
LoadLibrary to load third party library. So, I need to know the current
environment of my ASP .NET application. And also, there are some
initialization task will be done in Application_Sta rt( which is
Application-level ), So I also need to know the full life cycle of my ASP
.NET application to make sure that it can be initialized, unintialized, or
reinitialized properly.

Anybody have any advice would be great appreciated.

Thanks a lot,

Jim


Nov 19 '05 #6
re:
Thanks for your help --- Juan,

No sweat, Jim. Glad to be able to assist.

re: How can I access the Instance of Global which is
inherited from httpApplication class in my ASP.NET
page code?
If you're using codebehind for your Global.asax,
you'd need to call it like this in Global.asax:

<%@ Application Codebehind="Glo bal.asax.cs" Inherits="YourA pplicationName. Global" %>

That would assume that your codebehind for the ASP.NET
Application named "YourApplicatio nName" includes code
like this :

Global.asax.cs
---------------
using System;
using System.Collecti ons;
using System.Componen tModel;
using System.Web;
using System.Web.Sess ionState;
namespace YourApplication Name

{
/// <summary>
/// Summary description for Global.
/// </summary>

public class Global : System.Web.Http Application

{
protected void Application_Sta rt(Object sender, EventArgs e)

{
///Code for Application_Sta rt goes here
}

protected void Session_Start(O bject sender, EventArgs e)
{
///Code for Session_Start goes here
}

protected void Session_End(Obj ect sender, EventArgs e)

{
///Code for Session_End
}

protected void Application_End (Object sender, EventArgs e)

{
///Code for Application_End goes here
}

}
}
Again, this assumes that your Application "/YourApplication Name"
has been created and that you can access it as :

http:/www.yourwebserv er.com/YourApplication Name/

If you were doing this for an ASP.NET Application called "MyApp",
you could use this code in global.asax.cs :

using System.Web;
using System.Data;
public class MyApp : HttpApplication
{
public void Application_Sta rt ()
{
DataSet ds = new DataSet ();
ds.ReadXml ("GlobalData.xm l");
Application["GlobalData "] = ds;
}
}

Then, you could call it in Global.asax, like this :

<%@ Application Inherits="MyApp " %>

and you could reference Application["GlobalData "]
in your code in any aspx page as the source for
your Global Data.

Important: your application *must* have
been compiled in order for this to work OK.

Otherwise, you'll get an error message.

If you're not using codebehind, take a look at VB\Global.asax,
VB\Application2 .aspx and VB\SchemaData.x ml at :

http://samples.gotdotnet.com/quickst...plication2.src

If you use C#, there's links to the C# files, too.

There's a full example of setting a Global DataSource
in Global.asax, and retrieving it in an aspx page.
It's easier than it looks in this message. ;-)

Juan T. Llibre
ASP.NET MVP
===========
"jim" <ji*@discussion s.microsoft.com > wrote in message
news:DA******** *************** ***********@mic rosoft.com... Thanks for your help --- Juan,

I have another question: How can I access the Instance of Global which is
inherite from httpApplication class in my ASP.NET page code?

Thanks in advance.
Jim
"Juan T. Llibre" wrote:
An ASP.NET Framework application is created the first time
a request is made to the server; before that, no ASP.NET code
executes.

When the first request is made, a pool of HttpApplication
instances is created and the Application_Sta rt event is raised.

Nov 19 '05 #7

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

Similar topics

1
1774
by: jim | last post by:
Hi All, I like to know the life cycle of an ASP .NET Application( incudieng server application, such as .NET Web Service). That means from initialization to fully running and how to reboot it or shut it down. Including how to establish the running environment( current working folder, ...etc) for each ASP .NET application. Anybody have...
1
3505
by: athos | last post by:
Hi all, Believe you have sound experience in development, however, if we look at the whole Software Development Life Cycle (SDLC) of the project, say, 1. Project Initiation, 2. Gathering Requirements, 3. System Analysis and Design, 4. System Development,
2
1940
by: cmbardon | last post by:
I have a C# application that uses a C++ COM exe server, and I've noticed some strange behaviour with the life cycle of the object. In my .net app, I create an instance of the COM object (generated RCW), and am able to deal with methods and connection points without any real problems. The object is a member variable of the main client form....
2
1464
by: prem | last post by:
Hi, Iam new to ASP.NET. Any one can please give full description about ASP.Net life cycle. Thanks in Advance, Prem.
3
2316
by: | last post by:
Hi all, when are code render blocks rendered in asp.net page life cycle? what method does the code render block rendering? thanks! ingo
2
2010
by: Brian | last post by:
How static are static variables in ASP.NET? This is not a real example, but it's good enough to make the point. Say I have a custom control with a dictionary. The dictionary is composed of 10,000 strings read from a file and hashed. Obviously I don't want/need to rebuild the data structure for each page render. If it were a traditional...
16
2324
by: bharathi.vempati | last post by:
hi Can any one explain me the life cycle of C from source code to process termination. please make it fast k bye -ramya
1
2654
by: =?Utf-8?B?U2FtZWVrc2hh?= | last post by:
I vaguely know that HTTP Post does not send all the data (hidden fields?) along with the request. I would like to know the stage in ASP.Net application life cycle where the POST data is read - is it in HttpApplication.Init or at the time when viewstate / postback data is loaded? I am not able to find this type of info on MSDN or other sites....
4
3085
by: lander | last post by:
I've read the page life cycle thing in msdn, still, i'm getting a bit confused of thinking how all the things are going under the hood... I know that when page loading, that the controls' properties is populated and when page unloading, the resources are cleared. What I want to know is what's happening behind it, that is, from the...
0
7814
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7736
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8249
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6464
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5631
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5307
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3756
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2252
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1352
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.