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:

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 ( 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:

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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.