HttpRouteCollectionExtensions.MapHttpRoute Method (HttpRouteCollection, String, String, Object)

Maps the specified route template and sets default route values.

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


<ExtensionAttribute> _
Public Shared Function MapHttpRoute ( _
    routes As HttpRouteCollection, _
    name As String, _
    routeTemplate As String, _
    defaults As Object _
) As IHttpRoute
Dim routes As HttpRouteCollection
Dim name As String
Dim routeTemplate As String
Dim defaults As Object
Dim returnValue As IHttpRoute

returnValue = routes.MapHttpRoute(name, _
    routeTemplate, defaults)
public static IHttpRoute MapHttpRoute(
    this HttpRouteCollection routes,
    string name,
    string routeTemplate,
    Object defaults
static IHttpRoute^ MapHttpRoute(
    HttpRouteCollection^ routes, 
    String^ name, 
    String^ routeTemplate, 
    Object^ defaults
static member MapHttpRoute : 
        routes:HttpRouteCollection * 
        name:string * 
        routeTemplate:string * 
        defaults:Object -> IHttpRoute 
public static function MapHttpRoute(
    routes : HttpRouteCollection, 
    name : String, 
    routeTemplate : String, 
    defaults : Object
) : IHttpRoute


  • routeTemplate
    Type: System.String
    The route template for the route.
  • defaults
    Type: System.Object
    An object that contains default route values.

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 or

See Also


HttpRouteCollectionExtensions Class

MapHttpRoute Overload

System.Web.Http Namespace