简体   繁体   English

未找到与请求URI匹配的HTTP资源,未找到与控制器匹配的类型

[英]No HTTP resource was found that matches the request URI, No type was found that matches the controller

When i am hitting the url: http://localhost/api/adxxx/getDeals/?input=2 当我点击网址时: 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 '.", “ Message”:“未找到与请求URI'http:// localhost / api / adxxx / getDeals /?input = 2 '匹配的HTTP资源。”,

"MessageDetail": "No type was found that matches the controller named 'adxxx'." “ 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
}

How do i resolve this? 我该如何解决? Very similar apis having different route are working fine. 具有不同路由的非常相似的api可以正常工作。

This happened when i have added fluent validation to my api. 当我向我的api添加流利的验证时,就会发生这种情况。 That updated my System.Web.Http.dll to v5.2.3.0 那将我的System.Web.Http.dll更新到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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 没有找到与请求URI匹配的HTTP资源 - 并且 - 在控制器上找不到与请求匹配的操作 - No HTTP resource was found that matches the request URI - and - No action was found on the controller that matches the request 未找到与请求URI'Myurl'匹配的HTTP资源在与请求相匹配的控制器'controllername'上未找到操作 - No HTTP resource was found that matches the request URI 'Myurl' No action was found on the controller 'controllername' that matches the request 未找到与Angular 2中的请求URI匹配的HTTP资源 - No HTTP resource was found that matches the request URI in Angular 2 找不到与请求URI'MyUrl'匹配的HTTP资源 - No HTTP resource was found that matches the request URI 'MyUrl' 获取没有与请求URI匹配的HTTP资源 - Getting No HTTP resource was found that matches the request URI 找不到与请求URI匹配的HTTP资源 - No HTTP resource was found that matches the request URI 找不到与webapi中的请求URI匹配的HTTP资源 - No HTTP resource was found that matches the request URI in webapi 路由错误:找不到与请求URI匹配的HTTP资源 - Routing error: No HTTP resource was found that matches the request URI 自定义“找不到与请求uri匹配的http资源”消息 - Customizing “No http resource was found that matches the request uri” message 未找到与请求 URI 匹配的 HTTP 资源,我需要解决方案 - No HTTP resource was found that matches the request URI, I need solutions
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM