Working with Routes

At the heart of the ASP.NET routing feature is the idea of a URL pattern. When a URL is requested, the routing feature compares a list of patterns that you have provided and tries to match one of them to what has been requested. Here is an example of a routing URL:

/App/{page}/Action/{name}

URL patterns work on segments of a URL. A segment is a section of a URL delimited by the / character. Each segment in a pattern is represented by a literal value or a variable. Variables are expressed using braces ({ and }). In the previous pattern, there are four segments; two of the segments are literal (App and Action), and two are variables (page and name).

For a URL to match a URL pattern, there must be the same number of segments ...

Get Applied ASP.NET 4 in Context now with O’Reilly online learning.

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