Types of Web Pages XML

Web pages are of two types:

  • Static Web pages
  • Dynamic Web page

You can use the ASP.NET technology to create both types of Web pages. The following sections discuss static and dynamic Web pages in detail.

Static Web Pages

A static Web page is an .html file that consists of the HTML code. The data that you need to display in the Web page is contained in the HTML code. You cannot change the content of a static page after it is created. As a result, it is essential for the developer to be sure of the content before creating the Web page.

In addition, the content of a static Web page does not change depending on the user preference. This implies that in a static Web page, there is no mechanism by which you can tailor the Web page according to the user preference.

Creating a Sample Static Web Page

We will now create a sample static Web page by using HTML. Doing this will help you understand the concept of static Web pages.

To create a static Web page, perform the following steps:

  1. Open a Notepad file.
  2. Add the following code to the Notepad file:
  3. Save the file as Sample.htm. Saving the file as an .htm file converts the Notepad file into an HTML file.
  4. Open the file in a browser.

The previous code creates a sample Web page for a hypothetical organization, SomeOrganization, Inc. After saving the file as Sample.htm, you can open it in any browser, such as Internet Explorer or Netscape Navigator.

The Sample.htm file should look like Figure.

The Sample.htm File

The Sample.htm File

Accessing Static Web Pages

After you have created a Web page, you need to save it on a Web server. For example, the Web page that you created in the previous section, Sample.htm, is accessible only to a local user. To make it accessible to all users, you need to host the Web page on a Web server.

After you have hosted a Web page on a Web server, a URL address is assigned to it. Any user can then access the Web page by using its URL.

To access a Web page, the user needs to send in a request from a browser for the Web page. The request is then forwarded to the Web server, which converts the request to an HTML stream. The Web server then processes the HTML stream and sends the result back to the browser. The result is also in the form of an HTML stream. Finally, the browser processes the HTML stream and displays the result in the form of a Web page. This process is illustrated in Figure.

The Process of Accessing Static Web Pages

The Process of Accessing Static Web Pages

Limitations of Using Static Web Pages

As you can see, creating static Web pages is easy because it involves simple HTML coding. However, HTML has some limitations. For example, you cannot customize the Web page according to a user's preference. All users who access a static Web page see the same page. In addition, you can use HTML to display only static content.

Consider a situation in which you need to display a welcome thought in the Web page. You can do this by using HTML. However, if you want to update the welcome thought daily, you cannot do this using HTML alone. Consider another situation in which you want to display a welcome message to the user who accesses your Web page. In addition, you want to display the time when the user logs on to your page, as shown in Figure.

The Sample.htm Page

The Sample.htm Page

HTML does not allow you to display such dynamic features in a Web page. Another limitation of a static Web page is that the code behind the Web page is accessible to all users. This implies that any user can reuse your code to create their Web pages. To overcome these limitations, dynamic Web pages are used in a Web application. The following section discusses dynamic Web pages in detail.

Dynamic Web Pages

As the name suggests, dynamic Web pages allow you to display dynamic content. In contrast to static Web pages, in a dynamic Web page, the HTML code is generated after a user requests a Web page. This implies that you can customize the Web page to be displayed according to the preference of the user who makes a request for the page.

You can use two models to develop dynamic Web pages:

  • Server-side coding model
  • Client-side coding model

We will now discuss the two models of creating dynamic Web pages in detail.

Server-Side Coding Model

In the server-side coding model, when a user requests a Web page, the user needs to send a set of instructions to the browser. The browser then forwards the request and the set of instructions to the Web server. The Web server finds the file that contains these instructions and then creates an HTML stream based on the set of instructions. This enables the Web server to dynamically generate an HTML stream.

The HTML stream is passed on to the browser, which then processes it to display the Web page. The process of the server-side coding model is depicted in Figure.

The Server-Side Coding Model

The Server-Side Coding Model

Client-Side Coding Model

The client-side coding model is similar to the server-side coding model. However, in the client-side coding model, the set of instructions in the form of an HTML file is processed at the client side. For example, the user might need to customize the appearance of the Web page. To do this, the user preference needs to be included as a set of instructions that the client processes.

When a user requests a Web page, the request is passed to the Web server. The Web server locates the HTML page and creates an HTML stream. The HTML stream along with the set of instructions is sent back to the browser. The browser contains modules that process the HTML stream according to the instructions. The HTML page that is returned is then displayed in the browser. The process of the client-side coding model is displayed in Figure.

The Client-Side Coding Model

The Client-Side Coding Model

The client-side coding model has some limitations, as discussed in the following list:

  • Because the processing of a request takes place at the client side, different browsers might process the request differently, which could result in undesirable results.
  • The Web pages that are using the client-side model require a lot of time to download. This is because the files that contain the instructions are downloaded at the client side in addition to the Web page.
  • In the client-side coding model, the code behind a Web page is easily accessible to users who can use the code to create their Web pages.

As a result of the previously mentioned limitations, ASP.NET applications use server-side coding. These applications include ASP.NET Web applications and ASP.NET Web services. In this chapter, we will discuss how to create a simple ASP.NET Web application. You can use this knowledge to create a client application that requests a Web service. You will learn to create an ASP.NET Web service in "Creating an ASP.NET Web Service."


All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

XML Topics