Introduction to ASP

What Is ASP?

Microsoft Active Server Pages (ASP) is a server-side scripting environment that you can use to create and run dynamic, interactive Web server applications. 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. For example, you can use the ActiveX Data Objects (ADO) components to add database connectivity to your Web pages.

How ASP Works

When you incorporate ASP into your Web site, here's what happens:

  1. The user brings up a Web site where the default page has the extension .asp.
  2. The browser requests the ASP file from the Web server.
  3. The server-side script begins to run with ASP.
  4. ASP processes the requested file sequentially (top-down), executes any script commands contained in the file, and produces an HTML Web page.
  5. The Web page is sent to the browser.

The following illustration shows the transmission of dynamically generated content where the displayed date reflects the date at the time of the request.

Because your script runs on the server, the Web server does all of the processing and standard HTML pages can be generated and sent to the browser. This means that your Web pages are limited only by what your Web server supports.

Internet Information Services (IIS)

To run ASP on your computer you will need the Internet Information Services (IIS) component installed on your machine.

IIS 6.0 is included with Windows Server 2003 and is installed via the Add or Remove Programs item in the Control Panel. IIS 6.0 installs in a highly secure state, serving only static HTML content until other features and file types (such as ASP and ISAPI) are enabled.

IIS 5.1 comes with Windows XP Professional and is installed via the Add or Remove Programs item in the Control Panel.

IIS 5.0 comes with Windows 2000 Server and is installed by default. It also comes with Windows 2000 Professional and is installed via the Add or Remove Programs item in the Control Panel.

IIS 4.0 is available in Windows NT 4.0 Option Pack for Windows NT Server 4.0.

If you run Windows 98, Windows Me, Windows NT 4.0 Workstation, you can install Personal Web Server (PWS). PWS 4.0 is a scaled-down version of IIS. PWS is also available in Windows NT 4.0 Option Pack and Windows 98 CD.

Following are the instructions to install IIS component on a Windows XP Professional machine:

1. Place the Windows XP Professional CD-Rom into your Optical Drive.

2. Open Add/Remove Windows Components found in Add/Remove Programs in the Control Panel.

3. Check Internet Information Services (IIS) checkbox and click Next.

4. Once the installation is completed, you can view your home page by typing " into the address bar of your browser.

5. The default web directory to place the web site is in 'C:\Inetpub\wwwroot', but you can always set up your own virtual directory through the IIS Manager. For more information, see Creating Virtual Directories in IIS below.

Local IIS Web Sites

A local Internet Information Services (IIS) Web site is an IIS Web application on your computer. Creating or opening a local IIS Web site is useful in the following situations:

  • You want to test your Web site using IIS, which closely emulates how the Web site will run on a production server. This can have advantages over working with file system Web sites that run using the ASP Development Server, because paths are resolved as they will be on a production server.
  • You already have a set of Web site files in a folder and you want to test the Web site with IIS. In this case, you can create a virtual directory in your local version of IIS.
  • Your local computer is also your Web server.

Requirements
To create a local IIS Web site requires the following:

  • Your computer must have at least IIS version 4.0 installed and running.
  • ASP must be enabled in IIS version 6.0. To enable ASP by using IIS Manager, expand the local computer, and then click Web Service Extensions. In the details pane, click Active Server Pages, and then click Allow.
  • You must be logged in as a user with administrative privileges. This is required because working with the IIS metabase (where information about IIS applications is stored) requires administrative privileges.

To open an existing local IIS Web site, the preceding must be true as well as the following:

  • The site to be opened must be configured as an IIS application. For more information, see Creating Virtual Directories in IIS below.

Note: You can create an IIS application as a subfolder of any existing IIS folder.

Running Local IIS Web Sites
When you run a local IIS Web site to test it, launches a browser and runs the Web site using the server name localhost. For example, if you have created the Web site ExampleSite, when you test it, go to the following URL:

IIS resolves the application name, whether it points to a folder that is under the IIS root or to another location, and serves pages from that folder.

Deploying Local IIS Web Sites
Local IIS Web sites are generally used only for development, so that individual developers can create and test ASP Web pages on their own computers. In most cases, you must deploy the files from a file system Web site to a production server that is running IIS.

Creating Virtual Directories in IIS

In most cases, the content you publish to your Web or FTP site is located in a root or home directory on your computer, such as C:\Inetpub\wwwroot\. However, there might be instances when the content is located somewhere else, or even on a remote computer.

To publish from any directory not contained within your home or root directory, you can create a virtual directory. A virtual directory is a directory that is not contained in the home directory but appears to client browsers as though it were.

You can create a virtual directory through IIS Manager or by using Windows Explorer.

Important: You must be a member of the Administrators group on the local computer to perform the following procedures.

To create a virtual directory by using IIS Manager

  1. In IIS Manager, expand the local computer, expand the Web Sites folder, right-click the site or folder within which you want to create the virtual directory, point to New, and then click Virtual Directory. The Virtual Directory Creation Wizard appears.

  1. Click Next.
  2. In the Alias box, type a name for the virtual directory. (Choose a short name that is easy to type because the user types this name.)

  1. Click Next.
  2. In the Path box, type or browse to the physical directory in which the virtual directory resides, and then click Next.
    Note: This path is the root of your ASP Web application.

  1. Under Allow the following permissions, select the check boxes for the access permissions you want to assign to your users, you must select Read and Run scripts, and then click Next.
    Note: The IIS Manager UI only configures settings at the IIS scope, so the "Read", "Write", "Script source access", and "Directory browsing" check boxes only affect IIS-level behavior. These access controls in IIS have nothing to do with allowing/denying writing to an Access database or uploads, so enabling "Read" while disabling "Write", "Script source access", and "Directory browsing" definitely do nothing as far as denying writing to an Access database or uploads is concerned. Also see Configuring Permissions below.

  1. Click Finish. The virtual directory under the default website is created at the selected folder and is displayed in the IIS manager.

Note that the virtual directory setup as an ASP application is displayed with a icon. (The screenshot is from Windows 2003 server. The icon may be different in other versions of Windows.) Remember that this is the root of your ASP application. (If the virtual directory is not an ASP application, it is displayed with a icon, the application root for scripts under this directory will be an upper level virtual directory or website setup as ASP application.)
Right-click the Virtual Directory and then click Properties. If the virtual directory is an ASP application, the application root is displayed in the [Local path] textbox and the button next to [Application name] will be displayed as [Remove]. Otherwise, the button will be displayed as [Create] and you can click to make the virtual directory an application.
For real websites, e.g. if you use Web hosting, the application root is usually setup at the root of the website. For local IIS website during development, the application root is usually a virtual directory under the Default Web Site.

To create a virtual directory by using Windows Explorer

  1. Open Windows Explorer.
  2. Right-click the folder you want to be a virtual directory, and click Sharing and Security.
    Note: This folder will be the root of your ASP Web application.
  3. Click the Web Sharing tab.
  1. Click Share this folder.
  2. In the Alias box, type the name for the virtual directory.
  3. Click OK twice.

Note: You can not change the ASP version by using Windows Explorer.

Configuring Permissions

An important aspect of working with an Access .mdb file and file upload to a folder on the Web server is to correctly configure permissions.

When a Web application uses an Access database, the application must have Read permission to the .mdb file so the application can access the data. Additionally, the application must have Write permission to the folder that contains the .mdb file. Write permission is required because Access creates an additional file that has the extension .ldb in which it maintains information about database locks for concurrent users. The .ldb file is created at run time.

By default, the anonymous IIS user is IUSR_<MachineName>. Therefore, to use an Access database in an ASP Web application, you must configure the folder that contains the Access database to have both Read and Write permissions for the IUSR_<MachineName> user account.

If you specify database path, ASPMaker also creates the database folder but you may need to set the permissions yourself. To set permissions in the database folder,

  1. In Windows Explorer, move to the root folder for the Web site. e.g. C:\Inetpub\wwwroot\ExampleSite.
  2. If the database folder does not already exist, create one.
  3. Right-click the database folder, click Properties, and then click the Security tab.
  1. Under Group or user names, look for IUSR_<MachineName>.
  2. Verify that the account has Read and Write permissions for the database folder.

Similarly, set permissions in the folder where the uploaded file and audit trail log file reside.