Route.DataTokens Property
.NET Framework (current version)
Gets or sets custom values that are passed to the route handler, but which are not used to determine whether the route matches a URL pattern.
Assembly: System.Web (in System.Web.dll)
You use the DataTokens property to retrieve or assign values associated with the route that are not used to determine whether a route matches a URL pattern. These values are passed to the route handler, where they can be used for processing the request.
The following example shows how to create a Route object and 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
.NET Framework
Available since 3.5
Available since 3.5
Show: