| << 1.4.1- The Punctual Web Server Example | Chapter1 | 1.4.3- Creating and Editing ASP Scripts >> |
Common Errors and Pitfalls with ASP
If you had difficulty with the example above, then perhaps you fell into one of the simple traps that commonly snare new ASP programmers, and that can be easily rectified. In this section we'll look at a few common errors and reasons why your script might not run; if you did have problems, maybe this section will help you to identify the problem.
Program Not Found, or the Result of the ASP isn't being Displayed, or the Browser tries to Download the File
You'll have this problem if you try to view the page as a local file on your hard drive, like this:
C:\InetPub\wwwroot\BegASP\punctual.asp
|
You'll also get this problem if you click on the file in Windows Explorer. If you have Microsoft FrontPage or Visual InterDev installed, then it will start up and attempt to help you to edit the code. Otherwise, your browser may display a warning message:
|
|
|
Older browsers may try to download the file:
|
|
The Problem
That's because you're trying to access the page in a way that doesn't cause the ASP page to be requested from the web server. Because you're not requesting the page through the web server, the ASP doesn't get processed – and that's why you don't get the expected results of the ASP.
To call the web page through the web server and have the ASP processed, you need to reference the web server in the URL. Depending on whether you're browsing to the server across a local network, or across the Internet, the URL should look something like one of these:
http://chrisu/BegASP/punctual.asp
http://www.distantserver.com/BegASP/punctual.asp
Page Cannot be Displayed: HTTP Error 403
|
If you get the 403 error message, then it's probably because don't have permission to execute the ASP script contained within the page:
|
|
|
As you'll recall, the permissions are controlled by the properties of the virtual directory that contains the ASP page. To change these properties, you'll need to start up the IIS admin snap-in in the MMC, as we described earlier in the chapter. Find the BegASP virtual directory in the left pane, right-click on it and select Properties. This will bring up the BegASP Properties dialog that we met earlier in the chapter:
|
|
Here, you'll need to check that the value shown in the Execute Permissions box is Scripts only.
Page Cannot Be Found: HTTP Error 404
|
If you get this error message then it means that the browser has managed to connect to the web server successfully, but that the web server can't locate the page you've asked for. This could be because you've mistyped the URL at the browser prompt. In this case, you'll see a message like this:
|
|
If you get this page, then you might suspect one of the following errors:
- A simple typing error in the URL, e.g. http://chrisu/BegASP/punctually.asp
- Including a directory separator (/) after the file name, e.g. http://chrisu/BegASP/punctual.asp/
- Using the directory path in the URL, rather than using the alias, e.g. http://chrisu/Inetpub/wwwroot/BegASP/punctual.asp
- Saving the page as .html or .htm, rather than as an .asp, e.g. http://chrisu/BegASP/punctual.htm
|
Of course, it may be that you've typed in the URL correctly, and you're still experiencing this error. In this case, the most likely cause is that you have used Notepad to save your file and that (when you saved the file) it used its default Save As Type setting, which is Text Documents (*.txt). This automatically appends a .txt suffix to the end of your file name. In this case, you will unwittingly have finished up with a file called punctual.asp.txt.
To check if that is what happened, go to Windows Explorer, and view the (physical) folder that contains the file. Go to the Tools menu and select Folder Options…. Now, in the View tab, ensure that the Hide file extensions for known file types is unchecked, as shown here.
|
|
Now click OK and return to view your file in Windows Explorer. You may well see something like the following.
|
|
As you can see, Notepad has been less-than-honest in its dealings with you: when you thought that you had saved your file as punctual.asp, it had inconveniently saved it as punctual.asp.txt. Not surprisingly, your web server won't be able to find your file if it's been renamed accidentally. To correct the filename, right click on the filename in the right pane above, select Rename from the drop-down menu that appears and remove the .txt at the end.
Web Page Unavailable While Offline
|
Very occasionally, you'll come across the following message box:
|
|
This happens because you've tried to request a page and you haven't currently got an active connection to the Internet. This is a misperception by the server (unless your web server isn't the same machine as the one you're working on) – it is trying to get onto the Internet to get your page when there is no connection, and it's failing to realize that the page you've requested is present on your local machine. One way of retrieving the page is to hit the Connect button in the dialog; but that's not the most satisfactory of solutions (since you might incur call charges). Alternatively, you need to adjust the settings on your browser. In IE5, select the File menu and uncheck the Work Offline option.
This could also be caused if you're working on a network and using a proxy server to access the Internet. In this case, you need to bypass the proxy server or disable it for this page, as we described in the section Browsing to a Page on your Web Server, earlier in the chapter. Alternatively, if you're using a modem and you don't need to connect, you can correct this misperception by changing the way that IE looks for pages. To do this, select the Tools | Connections option and select Never dial a connection.
I Just Get a Blank Page
If you see an empty page in your browser then it probably means that you managed to save your punctual.asp without entering any code into it, or that you didn't remember to refresh the browser.
The Page Displays the Message but not the Time
If the web page displays the message In Webserverland, the time is exactly – but doesn't display the time – then you might have mistyped the code. For example, you may have missed the = symbol, by typing <% Time %>, or you might have misspelt the Time function, by typing <%= Tme %>.
I Get an Error Statement Citing Error ASP 0116 or 0x80004005
If you get a message stating that the page cannot be displayed, and citing an error code such as ASP 0116 or 0x80004005 then it means that there's an error in the ASP code itself. Usually, there's additional information provided with the message. For example, you'd get this error message if you had omitted the closing %> tag on your code.
I Have a Different Problem
If your problem isn't covered by this description, it's worth testing some of the sample ASP pages that are supplied with IIS and found in the InetPub/IISSamples directory. IISSamples is a virtual directory (just like the BegASP virtual directory that we have created), and it can be accessed in the same way, by typing the directory name after the server name – e.g. http://chrisu/IISSamples. These should help you to check that IIS has actually installed properly. You can always uninstall and reinstall if necessary.
You can get support from the book forum on http://p2p.wrox.com, which is our web site dedicated to support issues in this book. Alternatively, there are plenty of other web sites which are dedicated to the ASP cause. Here are just a couple:
There are lots of solutions, discussions and tips on these pages, plus click-throughs to other related pages. Moreover, you can try this web based newsgroup interface hosted by Microsoft:
So, by now you should have successfully downloaded, set up and installed IIS, created your first application in ASP, and been able to get it up and running. Let's look at some of the more popular editors with which you can create and edit ASP scripts.
| << 1.4.1- The Punctual Web Server Example | Chapter1 | 1.4.3- Creating and Editing ASP Scripts >> |

RSS









