我已配置以下
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
config.Routes.MapHttpRoute(
name: "DefaultApiWithAction",
routeTemplate: "api/{controller}/{action}/{id}",
defaults: new { id = RouteParameter.Optional }
);
并拥有以下网络API
public class MobileAppController : ApiController
{
[HttpGet, Route("api/mobileapp/services")]
public dynamic services()
{
return new { Abc = 123 };
}
}
调用http://localhost:123/api/mobileapp/services
时出错控制器上没有找到任何操作' MobileApp'符合名称' services'
答案 0 :(得分:-4)
将操作的返回值更改为IActionResult