ASP Overview
You can use Microsoft Active Server Pages (ASP) to create dynamic and interactive Web pages. An ASP page is a Hypertext Markup Language (HTML) page that contains script commands that are processed by the Web server before being sent to the client's browser. This explains how the term "server-side script" originated.
HTML Compared to ASP
HTML is the simplest language for writing Web pages, but it allows you to create only static Web pages. When a Web client requests a static HTML file from a Web server, the Web server sends the HTML file directly to the client without any computation being done. The client's browser then processes the HTML code in the file and displays the content.
The following illustration shows the transmission of a static file where the displayed date will never change.
VBScript is the simplest language for writing ASP pages. All the code samples in the Creating ASP Pages section are written in VBScript except for samples that are duplicated in JScript for comparison. When a Web client requests an ASP file from a Web server, the Web server sends the ASP file through its ASP engine, where all the server-side script code is executed or converted into HTML code. The converted code is then sent to the Web client.
The following illustration shows the transmission of dynamically generated content where the displayed date reflects the date at the time of the request.
If you are an HTML author, you will find that server-side scripts written in ASP are an easy way to begin creating more complex, real-world Web applications. If you have ever wanted to store HTML form information in a database, personalize Web sites according to visitor preferences, or use different HTML features based on the browser, you will find that ASP provides a compelling solution. For example, previously, to process user input on the Web server you would have had to learn a language such as Perl or C to build a conventional Common Gateway Interface (CGI) application. With ASP, however, you can collect HTML form information and pass it to a database using simple server-side scripts embedded directly in your HTML documents. If you are already familiar with scripting languages such as VBScript or JScript (JScript is the Microsoft implementation of the ECMA 262 language specification), you will have little trouble learning ASP.
ASP Processing
An ASP page is requested the same way that an HTML page is requested. A request can optionally contain a querystring after a question mark (?), using the following syntax:
http://Server_name/MyASPFile.asp?var1=12&var2=Brown
When the server receives a request for an ASP file, it processes server-side script code contained in the file to build the 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) as well as calls to COM components that perform a variety of tasks, such as connecting to a database or processing business logic.
IIS processes an ASP file in the following order when a request is received from a client:
If an ISAPI filter is installed on the Web site, the ISAPI filters is processed first. This is true for all applications.
If the ASP application contains a Global.asa file in the root directory, the Global.asa is processed. Global.asa files specify event scripts and declare objects that have session or application scope. They donot display content; instead they stores event information and objects used globally by the ASP application.
In the requested ASP file, IIS separates the script blocks from the static HTML code blocks, reserving the static code in the response body.
IIS processes the script blocks. The script blocks might include transaction processing, database access calls, or calls to COM components in which case COM+ handles some of the processing.
After the ASP page script blocks are processed, their output is injected into the response body with the static HTML code.
The response is sent to the client.
Warning
If you mix <SCRIPT> blocks with ASP code blocks (<% ... %>), the page might not execute in the order that you expect.
ASP and COM Components
With ASP, you can combine HTML pages, script commands, and COM components to create interactive Web pages or powerful Web-based applications, which are easy to develop and modify.
COM components dramatically extend the power of ASP. COM components are pieces of compiled code that can be called from ASP pages. COM components are secure, compact, and reusable objects that are compiled as DLLs. They can be written in Visual C++, Visual Basic, or other languages that support COM.