[英]No HTTP resource was found that matches the request URI - and - No action was found on the controller that matches the request
[英]No HTTP resource was found that matches the request URI, No type was found that matches the controller
当我点击网址时: http:// localhost / api / adxxx / getDeals /?input = 2
我收到以下错误:
“ Message”:“未找到与请求URI'http:// localhost / api / adxxx / getDeals /?input = 2 '匹配的HTTP资源。”,
“ MessageDetail”:“未找到与名为'adxxx'的控制器匹配的类型。”
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
config.DependencyResolver = new UnityResolver(UnityBootstrapper.Initialise());
config.EnableCors();
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "xxx.services",
routeTemplate: "webapi/{controller}/{action}"
);
config.Routes.MapHttpRoute(
name: "xxx.services_new",
routeTemplate: "api/{controller}/{action}",
defaults: new { id = RouteParameter.Optional }
);
FluentValidationModelValidatorProvider.Configure(config);
}
}
[Route("api/adxxx/getDeals/")]
public IHttpActionResult GetDeals(int input)
{
//code here
}
我该如何解决? 具有不同路由的非常相似的api可以正常工作。
当我向我的api添加流利的验证时,就会发生这种情况。 那将我的System.Web.Http.dll更新到v5.2.3.0
更正您的允许参数的路由配置
[Route("api/adxxx/getDeals/{input}")]
public IHttpActionResult GetDeals(int input)
{
//code here
}
然后您可以通过
http://localhost/api/adxxx/getDeals/2
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.