When i am hitting the url: http://localhost/api/adxxx/getDeals/?input=2
I get the following error:
"Message": "No HTTP resource was found that matches the request URI ' http://localhost/api/adxxx/getDeals/?input=2 '.",
"MessageDetail": "No type was found that matches the controller named '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
}
How do i resolve this? Very similar apis having different route are working fine.
This happened when i have added fluent validation to my api. That updated my System.Web.Http.dll to v5.2.3.0
Correct your route config for allow parameter
[Route("api/adxxx/getDeals/{input}")]
public IHttpActionResult GetDeals(int input)
{
//code here
}
and then you can request it by
http://localhost/api/adxxx/getDeals/2
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.