codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:



Home » ASP » Article

Application & Session Events in the Global.asax File

Article by: Jeff Anderson (9/24/2003)
Bookmark us now! Add to Favourites
Email a friend! Tell a friend
Sponsored by: FindMyHosting - Web Hosting Search
Summary: An introduction to the global.asax file and the application and sesion events that found there.
Viewed: 8685 times Rating (24 votes): 
 3.2 out of 5
  Rate this Article   Read Comments   Post Comments

Application & Session Events in the Global.asax File



Programmers familiar with ASP will know about the global.asa file. It's the place where application level events are handeled. The global.asax file is the ASP.Net equivalent and it can be found in the root directory of an ASP.Net application.

Here is the list of events you can call. By calling them you are actually overriding the event that is exposed by the HttpApplication base class.

Application_Start: 
As with traditional ASP, used to set up an application environment and only called when the application first starts.

Application_Init:
This method occurs after _start and is used for initializing code.

Application_Disposed: 
This method is invoked before destroying an instance of an application.

Application_Error: 
This event is used to handle all unhandled exceptions in the application.

Application_End: 
Again, like classic ASP, used to clean up variables and memory when an application ends.

Application_BeginRequest: 
This event is used when a client makes a request to any page in the application. It can be useful for redirecting or validating a page request.

Application_EndRequest:
After a request for a page has been made, this is the last event that is called.

Application_PreRequestHandlerExecute:
This event occurs just before ASP.Net begins executing a handler such as a page or a web service. At this point, the session state is available.

Application_PostRequestHandlerExecute: 
This event occurs when the ASP.Net handler finishes execution.

Application_PreSendRequestHeaders:
This event occurs just before ASP.Net sends HTTP Headers to the client. This can be useful if you want to modify a header

Application_PreSendRequestContent: 
This event occurs just before ASP.Net sends content to the client.

Application_AcquireRequestState: 
This event occurs when ASP.Net acquires the current state (eg. Session state) associated with the current request.

Application_ReleaseRequestState: 
This event occurs after ASP.NET finishes executing all request handlers and causes state modules to save the current state data.

Application_AuthenticateRequest:
This event occurs when the identity of the current user has been established as valid by the security module .

Application_AuthorizeRequest:
This event occurs when the user has been authorized to access the resources of the security module .

Session_Start: 
As with classic ASP, this event is triggered when any new user accesses the web site.

Session_End:
As with classic ASP, this event is triggered when a user's session times out or ends. Note this can be 20 mins (the default session timeout value) after the user actually leaves the site.






CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums
Rate this article:     Poor Excellent
View highlighted Comments
User Comments on 'Application & Session Events in the Global.asax File'


To post comments you need to become a member. If you are already a member, please log in .

 



RELATED ARTICLES
ASP Shopping Cart
by CodeToad Plus!
Complete source code and demo database(Access, though SQL compatible) to an ASP database driven e-commerce shopping basket, taking the user through from product selection to checkout. Available to CodeToad Plus! Members
Creating a Dynamic Reports using ASP and Excel
by Jeff Anderson
A simple way to generate Excel reports from a database using Excel.
ASP Format Date and Time Script
by Jeff Anderson
An ASP script showing the variety of date and time formats possible using the FormatDateTime Function.
Create an ASP SQL Stored Procedure
by Jeff Anderson
A beginners guide to setting up a stored procedure in SQL server and calling it from an ASP page.
Find Visitor Geographical location from IP address using ASP
by Per Soderlind
Where are your internet visitors coming from? Using simple ASP and the free GEOIP Database from Maxmind its quite easy to find out
The asp:checkbox and asp:checkboxlist control
by David Sussman, et al
Checkboxes are similar to radio buttons, and in HTML, they were used to allow multiple choices from a group of buttons.
Email validation using Regular Expression
by Jeff Anderson
Using regular expression syntax is an exellent way to thoroughly validate an email. It's possible in ASP.
Creating an SQL Trigger
by Jeff Anderson
A beginners guide to creating a Trigger in SQL Server
Complete ASP Chat Application
by Brian Gillham
A bonus for codetoad regulars - this is a chat application implemented entirely in ASP and is ready to run immediately.
ASP.NET Bar Chart Graph
by Chris Goldfarb
Complete source code to generate a horizontal bar chart graph in ASP.NET








Recent Forum Threads
•  ASPX page not showing
•  Calling ASP from Stored procedure
•  DISTINCT Function with Date string
•  Overflow: Scroll - Back to Top
•  Sessions
•  page in a cell
•  Re: open excel file in html page
•  urgent help with pop up menu layers that wont dissapear
•  Re: Swopping images using ASP


Recent Articles
ASP.NET Forum Source Code
Internal Search Engine
Javascript Growing Window
Simple date validation
Search engine friendly URLs using ASP.NET (C#.NET)
Function to Return Alpha Characters Only
The OSI Reference Model - A Clear and Concise Illustration !
Understanding Pointers to Functions in C
Application & Session Events in the Global.asax File
Socket Programming in Perl


Site Survey
Help us serve you better. Take a five minute survey. Click here!

© Copyright codetoad.com 2001-2004