.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Articles >> ASP.NET >> Post New Resource Bookmark and Share   

 Subscribe to Articles

ASP.NET page compilation facts

Posted By:Abhisek Panda       Posted Date: December 19, 2009    Points: 10    Category: ASP.NET    URL: http://www.dotnetspark.com  
 

              Let us consider an simple application for Login operation which has two files(Login.aspx and Login.aspx.cs). Then let us see what happens when the page is accessed for the first time. The below diagram describes what happens when an ASP.NET page is requested.



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 form's declarations and the controls it contains and is given the same name as the partial class that is defined by the code-behind file for that page(Login).

In step-2 the partial classes are compiled to create a single class that provides all the event handling code for that page. The result is stored in a single assembly. The class that is generated by ASP.NET runtime contains the code that creates the ASP.NET page. This class gets its name from the aspx file for the web page with _aspx (Login_aspx).

In step-3 this class is compiled and stored in another assembly. Because this class is inherited from the Login class, so an object that is instantiated from the Login_aspx class will contain the code that creates the page as well as the event handling code provided by the Login class.

In step-4, after the classes are compiled, the ASP.NET runtime calls C# compiler to compile any additional classes that are in the application's App_Code folder.

         After the files are compiled into assemblies, ASP.NET creates an instance of the page and calls the appropriate event. Then, the events are processed by event handlers and the HTML code for the page is created. The HTML code is then passed to the web server and to the client's browser.

           The above four stages are done only the first time an aspx page is called. When the user requests the page again the saved assemblies are reused, so the application do not need recompilation. If any of the source file is modified then ASP.NET automatically recompiles them.

For the default page the name of the code behind class is _Default.
 Subscribe to Articles

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend