Chapter 16. Routing

 

This chapter covers

  • Routing as a solution to URL issues
  • Designing a URL schema
  • Using routing in ASP.NET MVC
  • Testing routes
  • Using routing in Web Forms applications

So far in this book, we’ve stuck with the default routing configuration that comes with any new ASP.NET MVC project. In this chapter, we’ll cover the routing system in depth and learn how to create custom routes for our applications.

Routing is all about the URL and how we use it as an external input to the applications we build. The URL has led a short but troubled life, and the HTTP URL is currently being tragically misused by current web technologies. As the web began to change from being a collection of hyperlinked static documents into dynamically created pages and applications, the URL has been kidnapped by web technologies and undergone terrible changes, so that we now see file extensions like .aspx and .php mapping to physical files in public URLs. The URL is in trouble, and as the web becomes more dynamic, we, as software developers, can rescue it and bring back the simple, logical, readable, and beautiful resource locator that it was meant to be.

16.1. What are routes?

16.2. Designing a URL schema

16.3. Implementing routes in ASP.NET MVC

16.4. Using the routing system to generate URLs

16.5. Testing route behavior

16.6. Using routing with existing ASP.NET projects

16.7. Summary