【发布时间】:2015-11-24 04:00:12
【问题描述】:
我在 Startup.cs 中定义了以下路由:
app.UseMvc(routes =>
{
routes.MapRoute(
name: "api",
template: "api/{controller}/{action}/{id?}"
);
});
还有以下控制器:
public class BookmarksController : Controller
{
[HttpGet]
public string GetAll()
{
return "GetAll Action";
}
[HttpGet("{id}")]
public string Get(int id)
{
return "Get action";
}
}
谁能解释一下为什么我可以通过api/bookmarks/getall调用GetAllAction,但不能通过api/bookmarks/get/调用Get 3 ?
【问题讨论】:
标签: asp.net-web-api routing asp.net-core asp.net-core-mvc