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

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

.NET Framework 4.6 and 4.5

Provides a way to define routes for Web Forms applications.

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

public Route MapPageRoute(
	string routeName,
	string routeUrl,
	string physicalFile,
	bool checkPhysicalUrlAccess,
	RouteValueDictionary defaults,
	RouteValueDictionary constraints
)

Parameters

routeName
Type: System.String

The name of the route.

routeUrl
Type: System.String

The URL pattern for the route.

physicalFile
Type: System.String

The physical URL for the route.

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

defaults
Type: System.Web.Routing.RouteValueDictionary

Default values for the route.

constraints
Type: System.Web.Routing.RouteValueDictionary

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

Return Value

Type: System.Web.Routing.Route
The route that is added to the route collection.

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.

routes.MapPageRoute("ExpenseCurrentYearRoute",
    "ExpenseReportCurrent/{locale}", "~/expenses.aspx",
    false,
    new RouteValueDictionary 
        { { "locale", "US" }, { "year", DateTime.Now.Year.ToString() } },
    new RouteValueDictionary 
        { { "locale", "[a-z]{2}" }, { "year", @"\d{4}" } });

.NET Framework

Supported in: 4.6, 4.5, 4
Show:
© 2015 Microsoft