Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

RouteValueDictionary Class

Represents a case-insensitive collection of key/value pairs that you use in various places in the routing framework, such as when you define the default values for a route or when you generate a URL that is based on a route.

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

'Declaration
<AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level := AspNetHostingPermissionLevel.Minimal)> _
<AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level := AspNetHostingPermissionLevel.Minimal)> _
Public Class RouteValueDictionary _
	Implements IDictionary(Of String, Object),  _
	ICollection(Of KeyValuePair(Of String, Object)), IEnumerable(Of KeyValuePair(Of String, Object)),  _
	IEnumerable
'Usage
Dim instance As RouteValueDictionary

The RouteValueDictionary class enables you to work with collections of key/value pairs that are required in order to use ASP.NET routing. You use the RouteValueDictionary object to define values for the Constraints, DataTokens, and Defaults properties. You also use a RouteValueDictionary object when you generate a URL by calling the GetVirtualPath method and passing a RouteValueDictionary object as a parameter.

Every key in a RouteValueDictionary object must be unique. The RouteValueDictionary class uses case-insensitive ordinal comparison. For more information, see OrdinalIgnoreCase. A key cannot be Nothing.

The following example shows how to create a Route object and how to set the Constraints, DataTokens, and Defaults properties.

Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
    RegisterRoutes(RouteTable.Routes)
End Sub 

Shared Sub RegisterRoutes(ByVal routes As RouteCollection)
    Dim urlPattern As String 
    Dim reportRoute As Route

    urlPattern = "{locale}/{year}"

    reportRoute = New Route(urlPattern, New ReportRouteHandler)
    reportRoute.Defaults = New RouteValueDictionary(New With {.locale = "en-US", .year = DateTime.Now.Year.ToString()})
    reportRoute.Constraints = New RouteValueDictionary(New With {.locale = "[a-z]{2}-[a-z]{2}", .year = "\d{4}"})
    reportRoute.DataTokens = New RouteValueDictionary(New With {.format = "short"})

    routes.Add(reportRoute)
End Sub

System.Object
  System.Web.Routing.RouteValueDictionary

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

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

.NET Framework

Supported in: 3.5 SP1

Community Additions

ADD
Show:
© 2015 Microsoft