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

RouteCollectionExtensions.MapRoute Method (RouteCollection, String, String, Object, Object)

Maps the specified URL route and sets default route values and constraints.

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

public static Route MapRoute(
	this RouteCollection routes,
	string name,
	string url,
	Object defaults,
	Object constraints


Type: System.Web.Routing.RouteCollection
A collection of routes for the application.
Type: System.String
The name of the route to map.
Type: System.String
The URL pattern for the route.
Type: System.Object
An object that contains default route values.
Type: System.Object
A set of expressions that specify values for the url parameter.

Return Value

Type: System.Web.Routing.Route
A reference to the mapped route.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type RouteCollection. When you use instance method syntax to call this method, omit the first parameter. For more information, see b8020aae-374d-46a9-bcb7-8cc2390b93b6 or 175ce3ff-9bbf-4e64-8421-faeb81a0bb51.


The routes or url parameter is null.

© 2015 Microsoft