ASP.NET Tutorial

Intertech Tutorials

ASP.NET Tutorial Objective

Other than its name, Microsoft’s ASP.NET Web technology has very little in common with its predecessor, Active Server Pages (ASP). For example, ASP Web pages were created using server-side script - either with VBScript or JScript. The script was interpreted at run time to dynamically produce Web pages containing HTML and JavaScript.

ASP.NET creates Web pages dynamically, containing HTML and JavaScript, but with the Object-Oriented (OO) benefits of the .NET framework with C# and VB. Additionally, Visual Studio 2008 allows ASP.NET developers to employ the same development techniques used when building Windows applications. For example, a developer can “drag and drop” controls to the designer surface, set control properties, create event handlers, create an installer and more.

This chapter introduces the world of ASP.NET Web development. It examines the two different types of Visual Studio Web applications – Web Sites and Web Application projects. It also covers some of the new features in ASP.NET 3.5 and explores the new user interface of IIS 7.0.

The Architecture of a Web Application

A Web application follows the same architecture as a client/server application, which is based on the request/response paradigm. The client (usually a Web browser) is simply a computer that wants information. Information sent from the Web client to the Web server is termed the ‘request’. The server is simply a computer that has the information desired by others. Information sent from the Web server to the Web client is termed the ‘response’.

The fundamental technologies used with the Web are HTTP, HTML, JavaScript, Web browsers and Web servers.

HTTP Protocol

Communication between a Web client and a Web server is short. For example, a Web client (user) clicks on a hyperlink, forming and sending a request. The Web request is passed to the Web server, which generates and returns a response. Once the client has received the response from the Web server, the communication cycle is complete and the connection is terminated.

At this point, the Web server has no clue what the client is doing with the information it received. Unless the content is streamed information, no live connections are maintained between the client and the server. The Web server doesn’t even know if the client will make another request. Web applications are typically referred to as “stateless”.

In order to support the illusion that the client and server “know” each other, developers must use special client-side and server-side programming techniques. These techniques are used to sustain several concurrent Web sessions between many different Web clients with the same Web server. As you will learn later, ASP. NET provides numerous state management techniques, such as cookies, caching, session variables, hidden form fields, etc.

Understanding the Role of HTTP

The Hypertext Transfer Protocol (HTTP) is the most widely used protocol on the Internet today. HTTP is a simplified version of TCP/IP. Remember, HTTP is a stateless request/response protocol. The Web server does not automatically remember any state information between multiple requests from the same client.

A typical client/server interaction is as follows. A client sends a request using one of the following verbs: GET or POST. The request information includes the Uniform Resource Identifier (URI), protocol version, request modifiers, client information and sometimes form data (For example, text box values, check boxes, and drop-down list boxes). The server responds with the request status, the message protocol version, a success or error code, a message containing server information and possible body content (HTML).

The POST method is used to push a message from the client to the Web server. This technique is used when:

When a form is submitted using the POST method, the form data is embedded in the HTTP header:

POST /myBookServer HTTP/1.1
Cookie: NumVisits=2&UserID=22343243
Content-Type: text/xml
Content-Length: 500
Content: id=73&name=Chucky

The GET verb is similar to POST except that form data is appended to the query string. The Uniform Resource Locator (URL) with a query string looks something like this:

Query strings are typically limited to 255 characters by most Web browsers. Here is an HTTP GET message header:

8/8/00 10:20:37 Sent GET /myform/download.asp HTTP/1.1
Accept: application/msword, image/gif, image/jpeg,
Accept-Language: en-us
Cookie: NumVisits=2&UserID=22343243
User-Agent: Mozilla/4.0 (compatible; MSIE 5.0; Windows 2000)
Connection: Keep-Alive

ASP .NET hides much of the posting-centric mechanics. In most cases, you can be blissfully unaware of how the data is passed between the client and the server. Please note that, under the hood, ASP.NET is still using GET and POST verbs to move “stateful” message data.

Copyright (c) 2008-2013. Intertech, Inc. All Rights Reserved. This information is to be used exclusively as an online learning aid. Any attempts to copy, reproduce, or use for training is strictly prohibited.