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 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.