HttpRouteCollectionExtensions.MapHttpRoute Method (HttpRouteCollection, String, String, Object, Object, )
Maps the specified route template and sets default route values, constraints, and end-point message handler.
Namespace: System.Web.Http
Assembly: System.Web.Http (in System.Web.Http.dll)
Syntax
'Declaration
<ExtensionAttribute> _
Public Shared Function MapHttpRoute ( _
routes As HttpRouteCollection, _
name As String, _
routeTemplate As String, _
defaults As Object, _
constraints As Object, _
handler As HttpMessageHandler _
) As IHttpRoute
'Usage
Dim routes As HttpRouteCollection
Dim name As String
Dim routeTemplate As String
Dim defaults As Object
Dim constraints As Object
Dim handler As HttpMessageHandler
Dim returnValue As IHttpRoute
returnValue = routes.MapHttpRoute(name, _
routeTemplate, defaults, constraints, _
handler)
public static IHttpRoute MapHttpRoute(
this HttpRouteCollection routes,
string name,
string routeTemplate,
Object defaults,
Object constraints,
HttpMessageHandler handler
)
[ExtensionAttribute]
public:
static IHttpRoute^ MapHttpRoute(
HttpRouteCollection^ routes,
String^ name,
String^ routeTemplate,
Object^ defaults,
Object^ constraints,
HttpMessageHandler^ handler
)
static member MapHttpRoute :
routes:HttpRouteCollection *
name:string *
routeTemplate:string *
defaults:Object *
constraints:Object *
handler:HttpMessageHandler -> IHttpRoute
public static function MapHttpRoute(
routes : HttpRouteCollection,
name : String,
routeTemplate : String,
defaults : Object,
constraints : Object,
handler : HttpMessageHandler
) : IHttpRoute
Parameters
routes
Type: System.Web.Http.HttpRouteCollectionA collection of routes for the application.
name
Type: System.StringThe name of the route to map.
routeTemplate
Type: System.StringThe route template for the route.
defaults
Type: System.ObjectAn object that contains default route values.
constraints
Type: System.ObjectA set of expressions that constrain the values for routeTemplate.
handler
Type: HttpMessageHandlerThe handler to which the request will be dispatched.
Return Value
Type: System.Web.Http.Routing.IHttpRoute
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 HttpRouteCollection. 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).