ASP.NET
  Home arrow ASP.NET arrow Page 4 - An ASP.NET Web Application in Action
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

An ASP.NET Web Application in Action
By: Murach Publishing
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 2
    2009-06-24

    Table of Contents:
  • An ASP.NET Web Application in Action
  • The aspx code for the Order form
  • The Visual Basic code for the Order form
  • How an ASP.NET application is compiled and run
  • Perspective

  • 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


    An ASP.NET Web Application in Action - How an ASP.NET application is compiled and run


    (Page 4 of 5 )

    The diagram in figure 1-12 shows what actually happens behind the scenes when a user requests a page of an ASP.NET 3.5 application. In step 1, the ASP.NET runtime reads the aspx file for the requested web page and generates a class and a partial class. The partial class contains the declarations for the form and the controls it contains and is given the same name as the partial class that’s defined by the code-behind file for the page (Order in this example). In step 2, these partial classes are compiled to create a single class that provides all of the event-handling code for the page. The result is stored in a single assembly (dll file).

    The class that’s generated by the ASP.NET runtime contains the code that actually creates the ASP.NET page. This class gets its name from the aspx file for the web page plus _aspx, so its name is Order_aspx in this example. In step 3, this class is compiled and stored in another assembly. Because this class inherits the Order class, an object that is instantiated from the Order_aspx class will contain the code that creates the page, as well as the event-handling code provided by the Order class.

    In step 4, after the page classes are compiled, the ASP.NET runtime calls the Visual Basic compiler to compile any class files that are in the application’s App_Code folder. For the Shopping Cart application, this means that the CartItem and Product classes are compiled and the result is saved in a single assembly.

    After all the files are compiled into assemblies, ASP.NET creates an instance of the page and raises the appropriate events. Then, the events are processed by the event handlers for the page and the HTML for the page is rendered. To complete the round trip, the HTML document for the page is passed back to the web server and on to the user’s browser.

    Please note that the first four steps are done only the first time an aspx page is accessed. That’s because ASP.NET caches the assemblies that are created by these steps. Then, when the page is accessed again, the saved assemblies are reused, so the application doesn’t have to be recompiled. However, ASP.NET does compare the time stamps on the source files with the time stamps on the dll files. If any of the source files have been modified since they were last compiled, ASP.NET automatically recompiles them.

    How an ASP.NET application is compiled

    What happens when an ASP.NET page is requested

    1. The ASP.NET runtime processes the .aspx file and generates a partial class (Order) that contains the declarations for the form and its controls, and a class (Order_aspx) that contains the code that will initialize the form, instantiate the controls, and generate the HTML for the web page.
    2. The Visual Basic compiler compiles the partial class that contains the control declarations with the partial class defined by the code-behind file for the form into an assembly (.dll) that provides the event-handling code for the requested page. 
       
    3. The Visual Basic compiler compiles the Order_aspx class, which inherits the first compiled class (Order), and saves the result as an assembly that’s executed when the page is requested. 
       
    4. If necessary, the Visual Basic compiler compiles any other class files that are stored in the application’s App_Code folder. These classes are saved in a single assembly. 
       
    5. ASP.NET creates an instance of the page from the page’s final assembly. Then, ASP.NET raises the appropriate events, which are processed by the event handlers for the page, and the page generates the HTML that’s passed back to IIS for the response.

    Description

    1. The first four steps of this process are done only the first time the aspx page is requested. After that, the page is processed directly from the compiled assemblies.
    2. For the Default page, the name of the code-behind class is _Default.

    Figure 1-12  How an ASP.NET 3.5 application is compiled and run

    More ASP.NET Articles
    More By Murach Publishing


     

    Buy this book now. This article is an excerpt from chapter one of Murach's ASP.NET 3.5 Web Programming with VB 2008, written by Anne Boehm (Murach, 2008; ISBN: 1890774472). Check it out today at your favorite bookstore. Buy this book now.

    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 1 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek