473,394 Members | 1,759 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,394 software developers and data experts.

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_Start( 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 2612
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*@discussions.microsoft.com> wrote in message
news:66**********************************@microsof t.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_Start( 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_Start 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*@discussions.microsoft.com> wrote in message
news:66**********************************@microsof t.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_Start( 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_Start 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_Start 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_BeginRequest is raised at the start of an individual request.
Normally you do your request processing in the Page class.

Application_EndRequest 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
AuthenticateRequest
AuthorizeRequest
ResolveRequestCache
[A handler (a page corresponding to the request URL) is created at this
point.]
AcquireRequestState
PreRequestHandlerExecute
[The handler is executed.]
PostRequestHandlerExecute
ReleaseRequestState
[Response filters, if any, filter the output.]
UpdateRequestCache
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*@discussions.microsoft.com> wrote in message
news:66**********************************@microsof t.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_Start( 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*@discussions.microsoft.com> wrote in message
news:D5**********************************@microsof t.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_Start 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*@discussions.microsoft.com> wrote in message
| > news:66**********************************@microsof t.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_Start( 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_Start 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_Start 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_BeginRequest is raised at the start of an individual request.
Normally you do your request processing in the Page class.

Application_EndRequest 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
AuthenticateRequest
AuthorizeRequest
ResolveRequestCache
[A handler (a page corresponding to the request URL) is created at this
point.]
AcquireRequestState
PreRequestHandlerExecute
[The handler is executed.]
PostRequestHandlerExecute
ReleaseRequestState
[Response filters, if any, filter the output.]
UpdateRequestCache
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*@discussions.microsoft.com> wrote in message
news:66**********************************@microsof t.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_Start( 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="Global.asax.cs" Inherits="YourApplicationName.Global" %>

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

Global.asax.cs
---------------
using System;
using System.Collections;
using System.ComponentModel;
using System.Web;
using System.Web.SessionState;
namespace YourApplicationName

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

public class Global : System.Web.HttpApplication

{
protected void Application_Start(Object sender, EventArgs e)

{
///Code for Application_Start goes here
}

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

protected void Session_End(Object 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 "/YourApplicationName"
has been created and that you can access it as :

http:/www.yourwebserver.com/YourApplicationName/

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_Start ()
{
DataSet ds = new DataSet ();
ds.ReadXml ("GlobalData.xml");
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.xml 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*@discussions.microsoft.com> wrote in message
news:DA**********************************@microsof t.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_Start 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
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...
1
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...
2
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...
2
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
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
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...
16
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
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...
4
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'...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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.