Introducing ASP.NET - ASP.NET - Related Internet Concepts
(Page 2 of 5 )
This section is intended for those of you who are relatively new to web development. You are working with the latest technology available, but you still need some information to understand why ASP.NET is what it is. You may skip this section if you have experience with ASP or other web scripting technologies, but some of the information presented here may be new and interesting to you.
Common Gateway Interface Sharing information on the Internet is a simple process: A client machine uses a web browser to request a file from a web server, and the web server responds by sending the requested file. Improvements to that model include generating HTML dynamically by using the output of a program, which is executed on behalf of the web client. This is the purpose of the Common Gateway Interface (CGI): to execute a program on behalf of the web server (and by extension, the web client) and merge the output into the response.
ISAPI Filters The Internet Server Application Programming Interface (ISAPI) model was developed as a higher-performance alternative to CGI. ISAPI provides a number of advantages over CGI, including lower overhead, faster loading, and better scalability.
The chief difference between the CGI and ISAPI programming models is the way processing is handled. With CGI, the system creates a unique process for every request. Each time an HTTP server receives a request, it initiates a new process. Because the operating system must maintain all these processes, CGI is resource intensive. This inherent limitation makes it difficult to develop responsive Internet applications with CGI. With ISAPI, requests do not require a separate process. Threads are used to isolate and synchronize work items, resulting in a more efficient use of system resources.
Because ISAPI applications are compiled code, they are processed faster than ASP files or files that call COM components.
Internet Information Server On Windows systems, the default software that coordinates all the components of an HTTP request is the IIS server. IIS, along with the HTTP listener (HTTP.sys) handles the following tasks:
- Establishes and maintains HTTP connections
- Populates instances of the ASP and ASP.NET objects with available data from each HTTP request, such as session state information, error information, and client certificate information
- Passes a request body through a chain of possible destinations, as described in Table 3-1
- Populates an instance of the response object as a response is built during the processing of each request
- Modifies HTTP headers in a response according to configuration settings set by the administrator or page-level settings written by the application developer
- Sends HTTP responses back to clients
Table 3-1. Functions Performed by IIS
Request Type | Action Taken by IIS |
HTML page | IIS returns the page immediately in HTML format. |
ISAPI extension | IIS loads the ISAPI DLL (if it is not already running) and the request is sent to the extension. |
File name whose extension is mapped to a particular ISAPI extension | IIS loads the appropriate DLL file and presents the request to the extension. For example, requests for Active Server Pages (*.asp) files are resolved by invoking an ASP-specific extension module namedasp.dll. Likewise, requests for ASP.NET resources (for example,*.aspx,*.asmx,*.ashx) are mapped toaspnet_isapi.dll so that all requests for files with those extensions will be directed toaspnet_isapi.dll. The.stmand.shtmextensions are mapped tossinc.dll. |
CGI application | IIS creates a new process. IIS then provides the query string and other parameters that are included with the request through the environment and standard input (STDIN) handle for the process. |
Most of the non–Microsoft-related tasks just listed are also performed by many other kinds of web server software. However, we are only concerned with IIS as our Internet enabler. Later, we will take you through the creation of a web site in IIS, and that will put these concepts in perspective.
Layers in Web Request Processing It’s instructive to look at how all the components we’ve mentioned so far fit together. Today’s client/server applications resemble their linearly programmed ancestors so little that they’ve been given a new name: the multi-tier application, also known as n-tier architecture. In this model, processing is distributed between the client and the server, and business logic is captured in a middle tier. Most systems perform the following three main tasks, which correspond to three tiers, or layers, of the n-tier model. Table 3-2 describes the three tiers.
Table 3-2. Multi-Tier Architecture Layers
Task | Tier | Description |
User interface and navigation | Tier 1 | A graphical user interface so that users can interact with the application, input data, and view the results of requests. This layer is also responsible for formatting the data once the client receives it back from the server. In web applications, a browser performs the tasks of this layer. |
Business logic | Tier 2 | Components that connect the data sources with the presentation application. They are reusable pieces of code that can be changed without the need to change the whole application. Their tasks are logical functions, security checks, calculations, and so on. |
Data services | Tier 3 | Data services are provided by a structured (databases, XML databases) or unstructured (email programs, directories) data store, which manages and provides access to the data. |
Figure 3-2 shows how the Microsoft classic ASP technologies fit in this system architecture.

Figure 3-2. Classic ASP and IIS
The three-tier architecture isolates each major piece of ASP and component functionality so that the presentation (user interface) is independent of the processing rules and business logic, which in turn is separate from the data. This model requires much more analysis and design up front, but it greatly reduces maintenance costs and increases functional flexibility in the long run via reuse, easy maintenance, sectional upgrade, and so on. Of course, this is a Windows-based concept, but the principles are platform independent, which is why it has proved popular with most modern web projects. Let’s look at how ASP.NET uses the second tier to link the scripts, many more components, and server under one shell.
ASP and Other Web Scripts Microsoft Active Server Pages can be thought of as a type of ISAPI extension whose code is executed in real time (a script). More specifically, ASP is a server-side scripting environment that you can use to create dynamic and interactive web pages and build powerful web applications. With ASP, you can combine HTML pages, script commands, and COM components to create interactive web pages or powerful web-based applications that are easy to develop and modify.
When the server receives a request for an ASP file, it processes server-side script code contained in the file to build an HTML web page that is sent to the browser. In addition to server-side script code, ASP files can contain HTML (including related client-side scripts) and calls to COM components that perform a variety of tasks, such as connecting to a database or processing business logic.
Unlike conventional CGI applications, ASP was designed to simplify the process of developing web applications. By placing a few ASP tags in the appropriate places, you can add database connectivity or advanced customization features to a static page. ASP uses popular web scripting languages such as Microsoft JScript (the Microsoft implementation of the ECMA 262 language specification), Microsoft Visual Basic Scripting Edition (VBScript), or any COM-compliant scripting language, including JavaScript, Perl, and others.
This interactivity is valid for most other web scripting technologies. From the web programmer’s point of view, ASP may appear to be more intuitive than other scripted technologies by bringing the server execution to an HTML page (others, like PHP, also use the ASP paradigm); however, markup tags get dispersed with programming pieces, which can lead to code that is hard to read. In contrast, languages like Perl use code statements to create the page output, which is clearer but also creates code that looks more like a program than a web page.
Next: Active Server Pages .NET >>
More ASP.NET Articles
More By Apress Publishing
|
This article is excerpted from chapter three of the book ASP.NET Web Development with Macromedia Dreamweaver MX, written by Costas Hadjisotiriou et al. (Apress, 2004; ISBN: 1590593480). Check it out at your favorite bookstore. Buy this book now.
|
|