ASP Tutorial

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 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 (Figure 1). The client's browser then processes the HTML code in the file and displays the content.

Figure 1

VBScript is the simplest language for writing ASP pages. All the code samples in this tutorial 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 (Figure 2). The converted code is then sent to the Web client.

Figure 2

Unlike conventional Common Gateway Interface (CGI) applications, which are difficult to create, ASP is designed to greatly simplify the process of developing Web applications. With a few lines of script, you can add database connectivity or advanced customization features to your Web pages. In the past, you had to know PERL or C to add such functionality, but with ASP you can use ordinary Web scripting languages such as Microsoft JScript (Microsoft's implementation of the ECMA 262 language specification), Microsoft Visual Basic® Scripting Edition (VBScript), or any COM-compliant scripting language, including JavaScript, PERL, and others.

You can dramatically extend the power of ASP by using Component Object Model (COM) components in your ASP pages. 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.

The tutorial includes the following modules:

Before You Get Started...

This three-module tutorial provides step-by-step procedures and samples to help you implement ASP using VBScript. To load and run the tutorial samples, you must have administrator privileges on the computer running IIS. The default IIS security settings should allow you to run the tutorial, but you may need to change your security settings if you encounter access violations.

If you get an error when you open an ASP page in the browser, try the following:

If your problem persists, you do not have a generic error. Carefully read the error displayed in your browser to see whether you can determine where the error is coming from. Following are examples of possible errors and their explantations:

Web permissions are set in IIS with the IIS snap-in. However, those permissions can be undermined by NTFS permissions on specific files and folders. You may allow a user access to your Web site in IIS, but if NTFS file permissions deny access to an ASP file or a database file, your Web user does not see the file. If you are using Anonymous authentication, you must set NTFS permissions to allow access to the IWAM_ComputerName and IUSR_ComputerName accounts. Please see the sections in IIS Help about security and setting permissions, and see the IIS TechNet articles about NTFS Security.

If you did not customize your installation of IIS, x:\Inetpub\Wwwroot was created as the default home directory, where x is the drive on which you installed Windows. In x:\Inetpub\Wwwroot, make a directory called Tutorial. As you work through the lessons in each module, save your work in the x:\Inetpub\Wwwroot\Tutorial directory. View your work through your Web server by typing http://localhost/Tutorial/file_name.asp in your browser, where file_name.asp is the name of your file.

By default, Internet Explorer displays generic messages when there is an error in a Web page. You will want to see detailed error messages in Internet Explorer, so you need to disable the Internet Explorer feature that bypasses the errors sent from IIS. In Internet Explorer, click the Tools menu, select Internet Options, click the Advanced tab, and clear the Show Friendly HTTP Error Messages check box.

This tutorial does not contain:

 


© 1997-2001 Microsoft Corporation. All rights reserved.