ASP.NET
  Home arrow ASP.NET arrow Page 6 - ASP.Net Application
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ASP.NET

ASP.Net Application
By: O'Reilly Media
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 36
    2004-12-15

    Table of Contents:
  • ASP.Net Application
  • ASP.NET Mobile Web Applications
  • Application Structure and Boundaries
  • Application Boundaries
  • Application File Types
  • global.asax Files
  • .aspx Files
  • Code-Behind and Class Files

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    ASP.Net Application - global.asax Files


    (Page 6 of 8 )

    global.asax performs a similar function in ASP.NET that global.asa performs in classic ASP. That is, it is an optional file that may contain code to respond to Application-or Session-level events. Like global.asa in classic ASP, there can be only one global.asax file per ASP.NET application. Unlike the global.asa file in classic ASP, which was parsed, the global.asax application file is compiled at runtime into a .NET managed assembly ultimately derived from the HttpApplication class. In addition to handling Application-and Session-level events, such as Session_OnStart, global.asax also allows you to handle events raised by HttpModules associated with your application (in fact, the Session state in ASP.NET is implemented as an HttpModule, so its events are already handled this way).

    The global.asax file can be constructed one of two ways. The file can contain the event handlers and other code you want associated with your application directly, or it can reference a code-behind class file that contains the event handlers and code to associate with the application. Note that the code-behind used, if any, must inherit from the HttpApplication class in the System.Web namespace. The latter is the way that the global.asax files in ASP.NET applications created with Visual Studio .NET are constructed. Example 2-4 shows a typical global.asax file that uses code-behind, while Example 2-5 shows the code-behind file it uses.

    Example 2-4 . global.asax using code-behind

    <% -- Global.asax file-- %>
    <%@ Application Codebehind="Global.asax.vb" Inherits=" <namespacename>. Global" %>

    Example 2-5 . Code-behind file for global.asax in Example 2-4

    'Global.asax.vb codebehind file

    Imports System.Web
    Imports System.Web.SessionState

    Public Class Global
      Inherits System.Web.HttpApplication

      Sub Application_BeginRequest(ByVal sender As Object, _
        ByVal e As EventArgs)
        ' Fires at the beginning of each request
      End Sub

      Sub Application_AuthenticateRequest(ByVal sender As
        Object, _ ByVal e As EventArgs)
        ' Fires upon attempting to authenticate the user
      End Sub

      Sub Application_Error(ByVal sender As Object,
        ByVal e As EventArgs)
        ' Fires when an error occurs 
      End Sub

    End Class

    We’ll discuss the uses of the global.asax file in more detail in Chapters 13 and 19.

    This chapter is from ASP.NET in a Nutshell,  by G. Andrew Duthie. (O'Reilly, 2003, ISBN:  0596005202). Check it out at your favorite bookstore today. Buy this book now.

    More ASP.NET Articles
    More By O'Reilly Media


       · How are you Suriya
     

    ASP.NET ARTICLES

    - Adding Content to a Static ASP.NET Website
    - Building a Static ASP.NET Website in a Basic...
    - Develop Your First ASP.NET Website with Visu...
    - Run ASP.NET in Windows XP Home with Cassini ...
    - How to Test a Web Application
    - How to Add Code and Validation Controls to a...
    - Working in Source and Split Views to Build a...
    - How to Build a Web Form for a One-Page Web A...
    - How to Develop a One-Page Web Application
    - An ASP.NET Web Application in Action
    - Developing ASP.NET Web Applications
    - An Introduction to ASP.NET Web Programming
    - Introduction to the ADO.NET Entity Framework...
    - Completing an In-Text Advertising System und...
    - Programming an In-Text Advertising System un...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek