Partager via


RouteCollectionExtensions.MapHttpRoute Method (RouteCollection, 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.WebHost (in System.Web.Http.WebHost.dll)

Syntax

'Declaration
<ExtensionAttribute> _
Public Shared Function MapHttpRoute ( _
    routes As RouteCollection, _
    name As String, _
    routeTemplate As String, _
    defaults As Object, _
    constraints As Object, _
    handler As HttpMessageHandler _
) As Route
'Usage
Dim routes As RouteCollection 
Dim name As String 
Dim routeTemplate As String 
Dim defaults As Object 
Dim constraints As Object 
Dim handler As HttpMessageHandler 
Dim returnValue As Route 

returnValue = routes.MapHttpRoute(name, _
    routeTemplate, defaults, constraints, _
    handler)
public static Route MapHttpRoute(
    this RouteCollection routes,
    string name,
    string routeTemplate,
    Object defaults,
    Object constraints,
    HttpMessageHandler handler
)
[ExtensionAttribute]
public:
static Route^ MapHttpRoute(
    RouteCollection^ routes, 
    String^ name, 
    String^ routeTemplate, 
    Object^ defaults, 
    Object^ constraints, 
    HttpMessageHandler^ handler
)
static member MapHttpRoute : 
        routes:RouteCollection * 
        name:string * 
        routeTemplate:string * 
        defaults:Object * 
        constraints:Object * 
        handler:HttpMessageHandler -> Route
public static function MapHttpRoute(
    routes : RouteCollection, 
    name : String, 
    routeTemplate : String, 
    defaults : Object, 
    constraints : Object, 
    handler : HttpMessageHandler
) : Route

Parameters

  • routeTemplate
    Type: System.String

    The route template 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 routeTemplate.

  • handler
    Type: HttpMessageHandler

    The handler to which the request will be dispatched.

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 https://msdn.microsoft.com/en-us/library/bb384936(v=vs.108) or https://msdn.microsoft.com/en-us/library/bb383977(v=vs.108).

See Also

Reference

RouteCollectionExtensions Class

MapHttpRoute Overload

System.Web.Http Namespace