An Introduction to ASP.NET Web Programming

If you're just getting started with ASP.Net and looking for help, this is a good place to start. After reading this three-part series of articles, you should have a general understanding of how ASP.Net applications work and what software you'll need to develop these applications. 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).

Contributed by
Rating: 5 stars5 stars5 stars5 stars5 stars / 10
June 22, 2009
Rate this Article:
MEH MEH++


SEARCH ASP FREE
TOOLS YOU CAN USE

advertisement

This chapter introduces you to the basic concepts of web programming and ASP.NET. Here, you’ll learn how web applications work and what software you need for developing ASP.NET web applications. You’ll also see how the HTML code for a web form is coordinated with the Visual Basic code that makes the web form work the way you want it to. When you finish this chapter, you’ll have the background you need for developing web applications of your own.

An introduction to web applications

A web application consists of a set of web pages that are generated in response to user requests. The Internet has many different types of web applications, such as search engines, online stores, auctions, news sites, discussion groups, games, and so on.

Two pages of a Shopping Cart application

Figure 1-1 shows two pages of a simple web application. In this case, the application is for an online store that lets users purchase a variety of Halloween products, including costumes, masks, and decorations. You’ll see parts of this application throughout the book, so it’s worth taking the time to become familiar with it in this chapter.

The first web page in this figure is used to display information about the various products that are available from the Halloween store. To select a product, you use the drop-down list that’s below the banner at the top of the page. Then, the page displays information about the product including a picture, short and long descriptions, and the product’s price.

If you enter a quantity in the text box near the bottom of the page and click the Add to Cart button, the second page in this figure is displayed. This page lists the contents of your shopping cart and provides several buttons that let you remove items from the cart, clear the cart entirely, return to the previous page to continue shopping, or proceed to a checkout page.

Of course, the complete Halloween Superstore application also contains other pages. For example, if you click the Check Out button in the second page, you’re taken to a page that lets you enter the information necessary to complete a purchase.

An important point to notice about these pages is that they both contain controls that let the user interact with the page, like the drop-down list and buttons on the Order page. A page that contains controls like these is called a web form, and an ASP.NET application consists of one web form for each page in the application.

The Order page of a Shopping Cart application

The Cart page of a Shopping Cart application

Figure 1-1  Two pages of a Shopping Cart application

The hardware and software components for web applications

Figure 1-2 shows the basic hardware and software components that are required for a web application. To start, a web application is a type of client/server application, which means that the functions of the application are split between a client computer and a server computer. The client and server computers are connected to one another via the Internet, and they communicate with each other using HTTP, or Hypertext Transfer Protocol.

To access a web application, you use a web browser that runs on a client computer. By far the most popular web browser is Microsoft’s Internet Explorer, but two alternatives are Mozilla Firefox and Opera.

The web application itself is stored on the server computer. This computer runs web server software that enables it to send web pages to web browsers. Although many web servers are available, the two most popular are Microsoft’s Internet Information Services (or IIS) and The Apache Software Foundation’s Apache HTTP Server, which is usually just called Apache. For ASP.NET applications, though, the server must run IIS.

Because most web applications work with data that’s stored in a database, most server computers also run a database management system (or DBMS). Two popular database management systems for ASP.NET development are Microsoft SQL Server and Oracle. Note, however, that the database server software doesn’t have to run on the same server computer as the web server software. In fact, a separate database server is often used to improve an application’s overall performance.

Although this figure shows the client and server computers connected via the Internet, this isn’t the only way a client can connect to a server in a web application. If the client and the server are on the same local area network (or LAN), they can connect via an intranet. Since an intranet uses the same protocols as the Internet, a web application works the same on an intranet as it does on the Internet.

Components of a web application

Description

  1. Web applications are a type of client/server application. In that type of application, a user at a client computer accesses an application at a server computer. In a web application, the client and server computers are connected via the Internet or via an intranet (a local area network).
  2. In a web application, the user works with a web browser at the client computer. The web browser provides the user interface for the application. The most popular web browser is Microsoft’s Internet Explorer, but other web browsers like Mozilla Firefox and Opera may also be used. 
     
  3. The application runs on the server computer under the control of web server software. For ASP.NET web applications, the server must run Microsoft’s web server, called Internet Information Services, or IIS
     
  4. For most web applications, the server computer also runs a database management system, or DBMS, such as Microsoft’s SQL Server. The DBMS provides access to information stored in a database. To improve performance on larger applications, the DBMS can be run on a separate server computer. 
     
  5. The user interface for a web application is implemented as a series of web pages that are displayed in the web browser. Each web page is defined by a web form using HTML, or Hypertext Markup Language, which is a standardized set of markup tags. 
     
  6. The web browser and web server exchange information using HTTP, or Hypertext Transfer Protocol.

Figure 1-2  The hardware and software components for web applications

How static web pages work

Many of the web pages on the Internet are static web pages that don’t change in response to user input. These pages are HTML documents that are defined by HTML, or Hypertext Markup Language.

Figure 1-3 shows how a web server handles static web pages. The process begins when a user at a web browser requests a web page. This can occur when the user enters a web address, called a URL (Uniform Resource Locator), into the browser’s address box or when the user clicks a link that leads to another page.

In either case, the web browser uses HTTP to send an HTTP request to the web server. The HTTP request includes information such as the name and address of the web page being requested, the address of the browser making the request, and the address of the web server that will process the request.

When the web server receives an HTTP request from a browser, the server retrieves the requested HTML file from disk and sends the file back to the browser in the form of an HTTP response. The HTTP response includes the HTML document that the user requested along with the addresses of the browser and the web server.

When the browser receives the HTTP response, it formats and displays the HTML document. Then, the user can view the content. If the user requests another page, either by clicking a link or typing another web address in the browser’s address box, the process begins again.

Figure 1-3 also shows the components of a URL. The first component is the protocol, in this case, HTTP. In most cases, you can omit the protocol and HTTP is assumed.

The second component is the domain name, which identifies your web site. The URL in this figure, for example, includes the domain name for our web site, www.murach.com. The browser uses the domain name to identify the server that’s hosting the web site.

After the domain name, you specify the path where the file resides on the server. Notice that front slashes are used to separate the components of a path in a URL. After the path, you specify the name of the file you want to display in the browser. In this case, the file is a static web page named index.htm.

How a web server processes static web pages

The components of an HTTP URL

Description

  1. A static web page is an HTML document that is the same each time it’s viewed. In other words, a static web page doesn’t change in response to user input. Everyone who views a static web page sees exactly the same content.
  2. Static web pages are usually simple HTML files that are stored on the web server. When a browser requests a static web page, the web server retrieves the file from disk and sends it back to the browser. Static web pages usually have a file extension of .htm or .html. 
     
  3. A web browser requests a page from a web server by sending the server an HTTP message known as an HTTP request. The HTTP request includes, among other things, the name of the HTML file being requested and the Internet addresses of both the browser and the web server. 
     
  4. A user working with a browser can initiate an HTTP request in several ways. One way is to type the address of a web page, called a URL, or Uniform Resource Locator, into the browser’s address area and then press the Enter key. Another way is to click a link that refers to a web page. 
     
  5. A web server replies to an HTTP request by sending a message known as an HTTP response back to the browser. The HTTP response contains the addresses of the browser and the server as well as the HTML document that’s being returned.

Figure 1-3  How static web pages work

How dynamic web pages work

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

  1. 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.
  2. 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. 
     
  3. 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. 
     
  4. 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. 
     
  5. 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. 
     
  6. 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
     
  7. 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.

blog comments powered by Disqus
ASP.NET ARTICLES

- Implementing ASP.NET 4.0 Page.MetaDescriptio...
- ASP.Net Development Tips
- Intro to Sessions in ASP.Net
- Google Maps API Introduction in ASP.NET usin...
- Creating an ASP.NET 3.5 Gridview Image Galle...
- Encrypt QueryString in ASP.NET 3.5 using VB....
- ASP.NET 3.5 Drop Down List Controls
- Connect to Access Database with ASP.Net
- Secure Audio Streaming with ASP.Net and Flash
- Dynamic Sitemap and Navigation in ASP.Net
- Implement Gzip and Deflate Compression in AS...
- Run ASP.Net in Ubuntu with Apache
- ASP.Net Mono Website Contact Forms
- ASP.Net URL Rewriting Methods
- Murach`s ASP.NET 4 Web Programming with C# 2...

ASP Web Hosting ASP.Net Web Hosting Windows Web Hosting
ASP Free Forums 
 RSS  Tutorials RSS
 RSS  Forums RSS
 RSS  All Feeds
Site Map 
Request Media Kit
Write For Us Get Paid 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Privacy Policy 
Support 


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 7 - Follow our Sitemap
Most Popular Topics
All ASP.Net Tutorials