web api 2 routing - The resource cannot be found

后端 未结 1 600
粉色の甜心
粉色の甜心 2020-12-08 01:38

I\'ve added Web Api controller to MVC 5 application but all the time I get Error 404 - The resource cannot be found. I\'ve added GlobalConfiguration.Configure(WebApiConfig.R

相关标签:
1条回答
  • 2020-12-08 02:37

    WebApi routing started to work after I've changed the position of Register api method to be above of register routes:

        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            GlobalConfiguration.Configure(WebApiConfig.Register);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
        }
    
    0 讨论(0)
提交回复
热议问题