An Introduction to ASP.NET Web Programming - How dynamic web pages work
(Page 4 of 4 )
A web application consists of one or more web pages that are not static, but that can change in some way each time the page is displayed. Instead of being stored on disk in the form of HTML files, these pages are generated dynamically by the application. As a result, the generated pages are often referred to as dynamic web pages.
One of the key differences between static web pages and dynamic web pages is that dynamic web pages are web forms that contain one or more server controls, such as labels, text boxes, and buttons. Users work with these controls to interact with the application.
Figure 1-4 shows the basic processing for a dynamic web page. To start, the browser sends an HTTP request to the web server (IIS) that contains the address of the web page being requested, along with the information that the user entered into the form. When IIS receives this request, it determines that it’s a request for a web form rather than for a static web page. As a result, the web server passes the request on to the application server (ASP.NET) for processing. ASP.NET, in turn, manages the execution of the web form that’s requested.
To determine if the request is for a static page or a dynamic page, the web server looks up the extension of the requested page in a list of application mappings. These mappings indicate what program a file extension is associated with. For example, a static web page typically has an extension of htm or html, while a dynamic ASP.NET page has an extension of aspx. As a result, when the web server receives an HTTP request for an aspx file, it passes this request to ASP.NET, which processes the web form for that page.
When the web form is executed, it processes the information the user entered and generates an HTML document. If, for example, the web form displays data from a database, it queries the database to get the requested information. Then, it generates a page with that information, which is returned by ASP.NET to the web server. The web server, in turn, sends the page back to the browser in the form of an HTTP response, and the browser displays the page. This entire process that begins with the browser requesting a web page and ends with the page being sent back to the client is called a round trip.
When a user clicks on a control to start an HTTP request, it is called “posting back to the server,” which is referred to as a postback. In the Order form in figure 1-1, for example, the user starts a postback by selecting an item in the drop-down list or by clicking on the Add to Cart button. Then, the web form for the Order page is processed using the new values that the user has entered into the page.
Incidentally, the application server for ASP.NET 3.5 can handle requests for web forms that were developed by ASP.NET 2.0 as well as requests for forms that were developed by ASP.NET 3.5. That means that your old 2.0 web forms can run right along with your new forms, which means that you don’t have to convert your old applications to ASP.NET 3.5. Then, you can maintain your old web forms with ASP.NET 2.0 and develop your new web forms with 3.5.
How a web server processes dynamic pages

The URL for an ASP.NET web page
http://www.microsoft.com/express/product/ default.aspx
Description
A dynamic web page is an HTML document that’s generated by a web form. Often, the web page changes according to information that’s sent to the web form by the browser.
When a web server receives a request for a dynamic web page, it looks up the extension of the requested file in a list of application mappings to find out which application server should process the request. If the file extension is aspx, the request is passed on to ASP.NET for processing.
When the application server receives a request, it runs the specified web form. Then, the web form generates an HTML document and returns it to the application server, which passes it back to the web server and from there to the browser.
The browser doesn’t know or care whether the HTML was retrieved from a static HTML file or generated dynamically by a web form. Either way, the browser simply displays the HTML that was returned as a result of the request.
After the page is displayed, the user can interact with it using its controls. Some of those controls let the user post the page back to the server, which is called a postback. Then, the page is processed again using the data the user entered.
The process that begins with the user requesting a web page and ends with the server sending a response back to the client is called a round trip.
If you omit the file name from the URL when you use your browser to request a page, IIS will look for a file with one of four names by default: Default.htm, Default.asp, index.htm, and iisstart.asp. (If you’re using IIS 7.0, it will also look for a file with the name index.html or default.aspx.) If you want another page to be displayed by default, you can add the name of that page to this list. See appendixes A and B for more information.
Figure 1-4 How dynamic web pages work
Please check back tomorrow for the continuation of this series.
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |
|
This article is excerpted 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.
|
|