Skip navigation.

Personalization of Blogs - Your TakeAll recent postsBook Review: 250 HTML and Web Design Secrets

404 Reloaded

One of my first articles on this site was about custom error pages in ASP.NET. To me error handling is a big and important deal. The article I pointed you to explains how to tackle this challenge from different angles. However, my own custom 404 has been too simple. If you mistyped a URL is simply said, Sorry, I cannot find the page you are looking for. This was a little better than a "white screen" but still not good enough.

I decided to put to good use my naming convention. I assign reference names to blog posts and articles in a way that reflect their titles. For example, the URL of Microsoft.com Redesign: The Final Frontier is

http://www.aspnetresources.com/blog/ms_redesign_final.aspx

In reality, there's no page with this URL. An HTTP module routes it to a page that figures out which blog post to display. Since URLs somewhat resemble post titles I decided to reuse them for the purposes of handling 404s.

I set up a Full-Text Search catalog which is heads and shoulders better that the traditional LIKE construct in T-SQL. Luckily, in ASP.NET the offending URL is passed to your custom 404 page.

..../PageNotFound.aspx?aspxerrorpath=/missing_page_goes_here.aspx

By parsing it and feeding it to the search the site can provide suggestions as to what you might've been looking for. If the search renders nothing you get:

I cannot find the page you are looking for. I ran a site-wide search but still found nothing. Please check the archives.

If some suggestions were found you get this message along with a list of suggested links:

I cannot find the page you are looking for. I ran a site-wide search and found some posts and articles you might find relevant.

If something really, really weird happens you will be greeted with the simple, I cannot find the page you are looking for.

Comments

No comments yet

Emails and Notifications

Would you like to be notified when somebody responds to this post? 

Submit your comment

Please enter only text since all HTML tags except hyperlinks will be stripped. Hyperlinks will become live links. Any comments with flaming or offensive language will be deleted. Be courteous to other posters. Thank you.

Your name (required):
Your email (optional):
Your site's URL (optional):
Enter this number
Type in the number above:
Comment (required):