Chapter 4. Routes and URLs

Software developers are well known for paying close attention to the little details, especially when it comes to the quality and structure of their source code. We'll often fight long battles over code indentation styles and where curly braces should go. So it comes as a bit of a surprise when you approach a majority of sites built using ASP.NET and encounter a URL that looks like this:

http://example.com/products/list.aspx?id=17313&catid=33723&page=3

For all the attention we pay to code, why not pay the same amount of attention to the URL? It may not seem all that important, but the URL is a legitimate and widely used web user interface. Usability expert Jakob Nielsen (www.useit.com) urges developers to pay attention to URLs and provides the following guidelines for high-quality URLs:

  • A domain name that is easy to remember and easy to spell

  • Short URLs

  • Easy-to-type URLs

  • URLs that reflect the site structure

  • URLs that are hackable to allow users to move to higher levels of the information architecture by hacking off the end of the URL

  • Persistent URLs, which don't change

Traditionally, in many web frameworks such as classic ASP, JSP, PHP, ASP.NET, and the like, the URL represents a physical file on disk. For example, when you see a request for:

http://example.com/products/list.aspx

you could bet your kid's tuition that the web site has a directory structure that contains a products folder and a List.aspx file within that folder. In this case, there is a direct relationship ...

Get Professional ASP.NET MVC 2 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.