本文整理汇总了C#中HttpRouteCollection.MapHttpRoute方法的典型用法代码示例。如果您正苦于以下问题:C# HttpRouteCollection.MapHttpRoute方法的具体用法?C# HttpRouteCollection.MapHttpRoute怎么用?C# HttpRouteCollection.MapHttpRoute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpRouteCollection
的用法示例。
在下文中一共展示了HttpRouteCollection.MapHttpRoute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RegisterRoutes
public static void RegisterRoutes(HttpRouteCollection routes)
{
routes.MapHttpRoute("BeersRoute", "beers/{id}", new { controller = "Beer" }); // this one is needed only because beers vs. 1 beer are separated into 2 controllers
routes.MapHttpRoute("DefaultApi", "{controller}/{id}", new { id = RouteParameter.Optional });
routes.MapHttpRoute("BreweryBeersRoute", "breweries/{id}/beers", new { controller = "BeersFromBrewery" });
routes.MapHttpRoute("StyleBeersRoute", "styles/{id}/beers", new { controller = "BeersFromStyle" });
}
示例2: RegisterRoutes
private static void RegisterRoutes( HttpRouteCollection routes )
{
routes.MapHttpRoute( "Info", "", new { controller = "Game", action = "Info" } );
routes.MapHttpRoute( "User", "User", new { controller = "User" } );
routes.MapHttpRoute( "Game", "{action}", new { controller = "Game" } );
routes.MapHttpRoute( "Default", "{controller}/{action}" );
}
示例3: RegisterRoutes
public static void RegisterRoutes(HttpRouteCollection routes)
{
routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "docs/{id}",
defaults: new { controller = "Default", id = RouteParameter.Optional }
);
routes.MapHttpRoute(
name: "Default2Api",
routeTemplate: "{controller}/{id}",
defaults: new { controller = "Default", id = RouteParameter.Optional }
);
}
示例4: RegisterRoute
static void RegisterRoute(HttpRouteCollection routes)
{
routes.MapHttpRoute(
"get receipt",
"receipt",
new
{
controller = "Receipt",
action = "BuildReceipt"
},
new
{
httpMethod = new HttpMethodConstraint(HttpMethod.Post)
});
routes.MapHttpRoute("add promotion barcode",
"promotions/{Type}",
new
{
controller = "Promotion",
action = "AddPromotionBarcode"
},
new
{
HttpMethod = new HttpMethodConstraint(HttpMethod.Post)
});
routes.MapHttpRoute("get promotion barcodes",
"promotions/{Type}",
new
{
controller = "Promotion",
action = "GetBarcodesByType"
},
new
{
HttpMethod = new HttpMethodConstraint(HttpMethod.Get)
});
routes.MapHttpRoute("delete promotion barcodes",
"promotions/{Type}",
new
{
controller = "Promotion",
action = "DeleteBarcodesByType"
},
new
{
HttpMethod = new HttpMethodConstraint(HttpMethod.Delete)
});
}
示例5: RegisterRoutes
public static void RegisterRoutes(HttpRouteCollection routes)
{
routes.MapHttpRoute(
name: "Home",
routeTemplate: "",
defaults: new { controller = "Home", action = "Index" }
);
routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
}
示例6: Can_get_names_from_a_HttpRouteCollection
public void Can_get_names_from_a_HttpRouteCollection()
{
var routes = new HttpRouteCollection();
routes.MapHttpRoute("foo.show", "foo/{id}");
routes.MapHttpRoute("foo.one.two", "foo/{one}/{two}");
routes.MapHttpRoute("bar.show", "bar/{id}", defaults: new { id = RouteParameter.Optional });
routes.MapHttpRoute("bar.one.two", "bar/{one}/{two}",
defaults: new { one = RouteParameter.Optional, two = RouteParameter.Optional });
routes.MapHttpRoute("constraint", "constraints/{id:int}", null, new { id = @"\d+" });
var names = routes.GetNames();
Assert.True(names.Count == 5);
}
示例7: ConfigureHttpRoutes
private static void ConfigureHttpRoutes(HttpRouteCollection routes)
{
routes.MapHttpRoute(
name: "Courses",
routeTemplate: "",
defaults: new { controller = "Courses" }
);
routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
}
示例8: RegisterRoutes
public static void RegisterRoutes(HttpRouteCollection routes)
{
routes.MapHttpRoute(
name: ProductsWithDetailsRouteName,
routeTemplate: "api/products/details",
defaults: new
{
controller = "Products",
id = RouteParameter.Optional,
action = "Details"
});
routes.MapHttpRoute(
name: ProductsSoldOutRouteName,
routeTemplate: "api/products/{id}/mark-sold-out",
defaults: new
{
controller = "Products",
action = "MarkSoldOut"
});
routes.MapHttpRoute(
name: ProductsRouteName,
routeTemplate: "api/products/{id}",
defaults: new
{
controller = "Products", id = RouteParameter.Optional, action = "Default"
});
routes.MapHttpRoute(
name: CustomerAddressesRouteName,
routeTemplate: "api/customers/{id}/addresses",
defaults: new
{
controller = "Customers",
action = "AddressesForCustomer"
});
routes.MapHttpRoute(
name: CustomersRouteName,
routeTemplate: "api/customers/{id}",
defaults: new
{
controller = "Customers",
id = RouteParameter.Optional,
action = "Default"
});
}
示例9: Configure
private void Configure(HttpRouteCollection routes)
{
routes.MapHttpRoute(
"DefaultApiWithId",
"Api/TestDependency",
new { controller = "TestDependency" });
}
示例10: RegisterRoutes
/// <summary>
/// Routing registration.
/// </summary>
/// <param name="routes">The Http routes</param>
public static void RegisterRoutes(HttpRouteCollection routes)
{
routes.MapHttpRoute(
name: "AddWord",
routeTemplate: "AddWord/{word}",
defaults: new {controller = "Default", action = "AddWord"},
constraints: new {}
);
routes.MapHttpRoute(
name: "Count",
routeTemplate: "Count",
defaults: new {controller = "Default", action = "Count"},
constraints: new {}
);
}
示例11: RegisterRoute
static void RegisterRoute(HttpRouteCollection routes)
{
routes.MapHttpRoute(
"get receipt",
"receipt",
new
{
controller = "Receipt",
action = "BuildReceipt"
},
new
{
httpMethod = new HttpMethodConstraint(HttpMethod.Post)
});
routes.MapHttpRoute(
"create promotions",
"promotions/{promotionType}",
new
{
controller = "Promotion",
action = "CreatePromotion"
},
new
{
httpMethod = new HttpMethodConstraint(HttpMethod.Post)
});
routes.MapHttpRoute(
"get promotion barcodes",
"promotions/{promotionType}",
new
{
controller = "Promotion",
action = "GetPromotion"
},
new
{
httpMethod = new HttpMethodConstraint(HttpMethod.Get)
});
routes.MapRoute(
"promotions/{promotionType}",
"Promotion",
"DeletePromotion",
HttpMethod.Delete);
}
示例12: RegisterRoutes
public static void RegisterRoutes(HttpRouteCollection routes)
{
routes.MapHttpRoute(
name: "Leases",
routeTemplate: "leases/{resource}/{leaseId}",
defaults: new { controller = "Leases", resource = RouteParameter.Optional, leaseId = RouteParameter.Optional }
);
}
示例13: RegisterRoutes
internal static void RegisterRoutes(HttpRouteCollection routes)
{
routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
}
示例14: Configure
private static void Configure(HttpRouteCollection routes)
{
routes.MapHttpRoute(
"DefaultApiWithId",
"Api/{controller}/{id}",
new { id = RouteParameter.Optional },
new { id = @"\d+" });
}
示例15: ConfigureWebApiRoutes
private static void ConfigureWebApiRoutes(HttpRouteCollection routes)
{
routes.MapHttpRoute(
"API Default",
"api/{controller}/{id}",
new { id = RouteParameter.Optional }
);
}