public class UserController : BaseApiControllerAuth
{
public ArrayList GetPermissions()
{
enter code here
}
public UserModelCollection Get()
{
}
public UserModelCollection Get(fromuri id)
{
}
}
我的webapiconfig文件路由
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
config.Routes.MapHttpRoute(
name: "Defalutapi2",
routeTemplate: "api/{controller}/{action}/{id}",
defaults: new { action = "All", id = RouteParameter.Optional }
);
1.api / user /正在运行 2.api / user / 123正在运行 3.api / usr /权限给出错误找到了与请求匹配的多个操作
我怎么能解决这个问题?
答案 0 :(得分:0)
为什么不使用web api 2属性路由而不是传统的?
您可以使用属性路由执行以下操作:
[HttpGet]
[Route("ObtainData")]
public async Task<IHttpActionResult> ObtainData(string input){}
[HttpGet]
[Route("ObtainData2")]
public async Task<IHttpActionResult> ObtainData2(string input){}