Export (0) Print
Expand All

Route.Url Property

Gets or sets the URL pattern for the route.

Namespace:  System.Web.Routing
Assembly:  System.Web (in System.Web.dll)

member Url : string with get, set

Property Value

Type: System.String
The pattern for matching the route to a URL.


Any of the following:

  • The value starts with ~ or /.

  • The value contains a ? character.

  • The catch-all parameter is not last.


URL segments are not separated by a delimiter or a literal constant.

When you assign a value to the Url property, the / character is interpreted as a delimiter when the URL is parsed. Use braces ({}) to define a variable that is referred to as a URL parameter. The value from the matching segment in the URL is assigned to the URL parameter. Any values in the Url property that are not enclosed in braces are treated as literal constants.

The ? character is not allowed in the Url property. Each URL segment must be separated by either a delimiter or literal constant. You can use {{ or }} as escape characters for a brace character.

The following example shows how to set the Url property in the class constructor. The pattern contains the literal value "Category" for the first segment and URL parameters for the next two segments.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

© 2014 Microsoft