O'Reilly logo

Professional ASP.NET MVC 5 by David Matson, K. Scott Allen, Brad Wilson, Jon Galloway

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 9Routing

—by Phil Haack and David Matson

What's In This Chapter?

  • Understanding URLs
  • Introduction to Routing
  • A peek under the Routing hood
  • A look at advanced Routing
  • Routing extensibility and magic
  • Using Routing with Web Forms

When it comes to source code, software developers are notorious for fixating on little details to the point of obsessive compulsion. We'll fight fierce battles over code indentation styles and the placement of curly braces. In person, such arguments threaten to degenerate into all-out slap fights.

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/albums/list.aspx?catid=17313&genreid=33723&page=3.

For all the attention we pay to code, why not pay the same amount of attention to the URL? It might not seem important, but the URL is a legitimate and widely used user interface for the Web.

This chapter helps you map logical URLs to action methods on controllers. It also covers the ASP.NET Routing feature, which is a separate API that the ASP.NET MVC framework makes heavy use of to map URLs to method calls. The chapter covers both traditional routing as well as the new attribute routing introduced in ASP.NET MVC 5. The chapter first covers how MVC uses Routing and then takes a peek under the hood at Routing as a standalone feature.

UNIFORM RESOURCE LOCATORS

Usability expert Jakob Nielsen (www.useit.com) urges developers to pay attention to URLs ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required