MapPageRoute Method (String, String, String, Boolean, RouteValueDictionary, RouteValueDictionary, RouteValueDictionary)

RouteCollection.MapPageRoute Method (String, String, String, Boolean, RouteValueDictionary, RouteValueDictionary, RouteValueDictionary)

.NET Framework (current version)

Provides a way to define routes for Web Forms applications.

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

Public Function MapPageRoute (
	routeName As String,
	routeUrl As String,
	physicalFile As String,
	checkPhysicalUrlAccess As Boolean,
	defaults As RouteValueDictionary,
	constraints As RouteValueDictionary,
	dataTokens As RouteValueDictionary
) As Route


Type: System.String

The name of the route.

Type: System.String

The URL pattern for the route.

Type: System.String

The physical URL for the route.

Type: System.Boolean

A value that indicates whether ASP.NET should validate that the user has authority to access the physical URL (the route URL is always checked). This parameter sets the PageRouteHandler.CheckPhysicalUrlAccess property.

Type: System.Web.Routing.RouteValueDictionary

Default values for the route parameters.

Type: System.Web.Routing.RouteValueDictionary

Constraints that a URL request must meet in order to be processed as this route.

Type: System.Web.Routing.RouteValueDictionary

Values that are associated with the route that are not used to determine whether a route matches a URL pattern.

Return Value

Type: System.Web.Routing.Route

The route that is added to the route collection.

Exception Condition

The routeUrl parameter is null.

This method is provided for coding convenience. It is equivalent to calling the Add method and passing a Route object that is created by using the PageRouteHandler class.

The following example shows how to define a route by using this method. This example is part of a larger example that is available in the MapPageRoute method overview.

    "ExpenseReportDetail/{locale}/{year}/{*queryvalues}", "~/expenses.aspx",
    new RouteValueDictionary(New With _
        { .locale = "US", .year = DateTime.Now.Year.ToString()}),
    new RouteValueDictionary(New With _ 
        { .locale = "[a-z]{2}", .year = "\d{4}" }),
    new RouteValueDictionary(New With _
        { .account = "1234", .subaccount = "5678" }))

.NET Framework
Available since 4.0
Return to top
© 2016 Microsoft