You are viewing a plain-jane printable version of http://CoverYourASP.com/404Descr.asp.See how this was done
| |
Everyone has seen an HTTP 404 error at some point. You follow a link on a web page, and BOOM - File not found. Perhaps the author spelt it incorrectly, or the page was uploaded to the server by mistake. I'll show you how to handle this gracefully*, and send an email to yourself so the problem gets fixed. But first, what did I mean when I said "Make money from error handling"? I was authoring a site last year that wanted to offer customers their own websites. While thinking about the URL's I should give them I got to thinking about Bigfoot. I have long had Bigfoot redirect traffic to this site from a generic "http://www.Bigfoot.com/~jamesandtara" URL that's been around for years. All of a sudden I had one of those Eureka moments! I'd just give my customers a URL such as "http://CoverYourASP.com/~Yourname". This is already a common form of URL found on many sites who have "members pages". The next step was easy. I wrote a page that would handle the 404 File not found errors, and checked if they started with a '~' character. Any that did I looked up in my database and served up their page from that data. Hey presto, unlimited website URL's for everyone! To demonstrate the principle, here are 3 URL's that don't exist on this site. Click on them to see the results. NoFile.asp - this file doesn't exist. Apologize to the user, and send myself a mail to fix the problem using CDONTS. UPDATE: I had an interesting experience last night. My web site started sending emails as fast as it could informing me of missing files. I got over 500 before I FTP'd onto the server and deleted the Handle404.asp file. The reason was a "spider" crawling my page - it had got onto this page and was trying to get to the ~James page shown above. Unfortunately it had interpreted the lack of file extension as a folder name and had helpfully appended a trailing /. Things went downhill from there because all my hyperlinks from that page are relative, not absolute. Do you see where this is leading? Because the spider had asked for a new folder called ~James my relative links were all broken, and generated 404's themselves! I hate to think how many emails I would have got if I was on vacation... The moral of the story: Always use absolute paths in the 404 handling page, or use a <base href="http://youdomain.com/"> tag to keep all your URL's relative to that rather than the current file. * I don't need to describe how to setup IIS to use custom error handling - it's fully described in the IIS help - just browse to your local IISHELP documentation. |