📜  webapi 路由 - 任何代码示例

📅  最后修改于: 2022-03-11 14:57:37.336000             🧑  作者: Mango

代码示例1
// All parameters are required, or it won't match.
// So it will only match URLs 4 segments in length
// starting with /api.
config.Routes.MapHttpRoute(
     "1",
     "api/{controller}/{id}/{action}"
);

// Controller is required, id is optional.
// So it will match any URL starting with
// /api that is 2 or 3 segments in length.
config.Routes.MapHttpRoute(
    "2",
    "api/{controller}/{id}",
    new { action = "get", id = RouteParameter.Optional }
);