To use Active Server Pages (ASP) files you need a Web server that supports ASP. For most people using modern Microsoft Windows Operating Systems, this will be Microsoft Internet Information Server (IIS).
You might be wondering why we are talking about a web server, as Internet Explorer can open Web files directly from the Windows Explorer. The trouble is that ASP files don't work if opened this way. Why is that? Well, a standard HTML file just contains text and HTML tags to tell the browser what the text should look like. There's an important point there - the HTML is interpreted by the browser. So the browser needs nothing else to be able to display a standard HTML page.
An ASP file however, is different, because not only does it contain HTML, it also contains scripting code. This is code, much like VBA, that is run by the Web server, before the ASP file is sent to the browser. In the case of the ASP pages shown in Chapter 18, here's what happens:
The user requests the ASP page.
The Web server finds the page and looks at the script in it. ASP script is contained within angle brackets as < % % > anything within with the script tags is sent to the ASP engine where it is executed.
The script connects to the database and extracts the data.
The script then formats the data into HTML.
The Web server sends the HTML back to the user.
So the user only receives HTML, but to get that HTML the page has to be processed by a Web server. That's why we just can't open an ASP page directly in the browser - it has to go via the Web server.
IIS is provided with Microsoft Windows 2000 and Windows XP Professional. It's not installed by default, but contains a simple installation program. You can install IIS from your computer's Control Panel , under the Add/Remove Programs option:
IIS is a very capable web server, but one thing you must do when using this product is to make sure you keep all security patches up-to-date. Microsoft's web servers remain a top target for web hackers, so on live systems, you should always be aware of security.
You can create a virtual directory from the Internet Information Services icon in Administrative Tools . This open the IIS Management Console:
Select the Default Web Site
Right-click and select New Virtual Directory from the context menu:
This opens the Virtual Directory Creation Wizard which will take you through the process of creating a virtual directory.
In the first Wizard Screen simply click Next
Enter an Alias for the new directory (the name you'd like to use in its URL). For our examples we've chosen BegVBA :
Click Next . Then enter the path (or use the browser button) to indicate the physical location of your database:
Click Next . The following screen allows you to set permissions for access to the virtual directory:
We don't need to anything special for our example, so just accept the defaults and click Next to finish the set up
That's it. You have set up your first virtual directory using Windows XP Professional.
On the permissions screen you may have noticed the option Browse . Browsing - if no explicit document is requested , and there is no default document in the directory, then a listing of the directory is returned, much like a listing of files in Windows Explorer.
Directory browsing is extremely useful when testing as it allows you to quickly select files in the browser without having to explicitly type them in the URL. However, you should be wary of using directory browsing on live machines as it gives a complete list of every file in the virtual directory.
Most URL's you see start with www , but if you are using your own machine you might not have a www address set up. To get around this problem you can contact your local machine by the following:
This replaces the root part of the URL, and you can then add your virtual directories onto the end of this (you add the name of the virtual directory, not the name of the folder that you created it from):
If you've got directory browsing enabled, and there's no default document, then this will show you a directory listing. Or, you can specify a document:
This tells the web server to fetch the specified ASP file.
If you experience any difficulties setting up your DSN, or getting your Virtual Directories to work, remember that you can get assistance from email@example.com