![]() |
|
|
Published: Monday, July 31, 2000 By Nathan Pond "404 - File Not Found" We've all seen this hundreds of times. As hard as we all try to spare our users from seeing such a thing, the simple fact is there is no way to prevent this from happening. However, configuring IIS 4.0 and using some simple ASP can display a custom, formatted page to the user while at the same time logging the incorrect URL to a database or sending the webmaster an e-mail. You can not afford to wait for your users to report incorrect links on your site, you want to be notified when the error happens. In this article I'll explain how you can do that.
Keep in mind that you don't have to log errors, you may simply just want to use your own 404 page instead of the default one that shows on the users browser. In either case, the first step is to create the custom 404 page that you want to show to the user. You can be as creative as you want with this, some web sites have very humorous 404 pages. You can visit http://www.npond.com/404.shtml to see what I did with mine, maybe give you some ideas.
You have your page created, at least the html part of it. We'll get the ASP in a little bit. The next step is
to configure IIS to send your 404 file whenever it can't find the file specified by the users browser. To do this
open Microsoft Management Console (MMC). You may make the 404 page you have work for your entire server, only
specified webs, or even specified directories within a web. For now we will configure one web on your web
server to use this 404 page. Right click on the name of the web you wish to configure, and click on
Now a dialog window pops up and gives you the option to select the
Click the
When a 404 error is triggered, IIS will direct the user to your custom ASP script and pass the incorrect URL
in the querystring. All we need to do is parse it. We can also use Server Variable
This code will assign the strURL variable with the incorrect URL that the user tried to access. It will also
put the refering page into the strReferer variable. Now it is a simple matter of sending an e-mail using
CDONTS (or some other component) and/or loggin this information to a database. Note that if For information on using CDONTS to send e-mail from ASP, please see: Sending Emails in ASP using CDONTS. Happy Programming!
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() |
![]() |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||