RouteCollectionExtensions.MapRoute Method (RouteCollection, String, String, Object, Object, String[])
Maps the specified URL route and sets default route values, constraints, and namespaces.
Namespace: System.Web.Mvc
Assembly: System.Web.Mvc (in System.Web.Mvc.dll)
static member MapRoute : routes:RouteCollection * name:string * url:string * defaults:Object * constraints:Object * namespaces:string[] -> Route
Parameters
- routes
- Type: System.Web.Routing.RouteCollection
A collection of routes for the application.
- name
- Type: System.String
The name of the route to map.
- url
- Type: System.String
The URL pattern for the route.
- defaults
- Type: System.Object
An object that contains default route values.
- constraints
- Type: System.Object
A set of expressions that specify values for the url parameter.
- namespaces
- Type: System.String[]
A set of namespaces for the application.
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 https://msdn.microsoft.com/en-us/library/bb384936(v=vs.108) or https://msdn.microsoft.com/en-us/library/bb383977(v=vs.108).| Exception | Condition |
|---|---|
| ArgumentNullException | The routes or url parameter is a null reference (Nothing in Visual Basic). |
Show: