我在我的 中设置了以下两个操作ApiController
:
[POST("api/admin/image/{id}/upload")]
[Authorize(Roles = RoleNames.Administrator)]
public Foo UploadVersion(int id)
public Bar Post(int id, Baz x) {}
鉴于此路由配置,它们是冲突的:
context.Routes.MapHttpRoute(
name: "Admin_Api",
routeTemplate: "api/admin/{controller}/{id}",
defaults: new
{
id = RouteParameter.Optional
});
我的猜测是,它UploadVersion
也会通过路由映射获得某种默认路由,但我该如何防止呢?
如果有人想知道我要做什么:
POST /api/admin/image/{id}/upload -> UploadVersion()
POST /api/admin/image/{id} -> Post()