Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
默认 webapi 路由 - api/{controller}/{id}
在实时场景中可能需要更多的 get 和 post 方法
是否建议像默认路由一样更改此设置 - api/{controller}/{action}/{id}
通常默认值是推荐值。除非您有特殊要求,否则您无需更改此设置。
api/{controller}/{controller}/{id}毫无意义,因为您不必在 URL 中显示两倍的控制器名称。
api/{controller}/{controller}/{id}
{action}并非每次都需要(如果使用 GET/PUT ...)。您可能希望创建api/{controller}/{action}/{id}为第二条路由或{action}在默认路由中指定为UrlParameter.Optional.
{action}
api/{controller}/{action}/{id}
UrlParameter.Optional