Asp.net web api Asp.Net WebAPI和AttributeRouting-没有重载的属性构造函数?

Asp.net web api Asp.Net WebAPI和AttributeRouting-没有重载的属性构造函数?,asp.net-web-api,asp.net-web-api-routing,attributerouting,Asp.net Web Api,Asp.net Web Api Routing,Attributerouting,我刚刚下载了用于WebAPI的AttributeRouting NuGet软件包,我的控制器中出现了一个问题。 我认为使用它的方法是: public class InboxController : ApiController { private IInboxService _inboxService; public InboxController(IInboxService inboxService) { _in

我刚刚下载了用于WebAPI的AttributeRouting NuGet软件包,我的控制器中出现了一个问题。 我认为使用它的方法是:

 public class InboxController : ApiController
    {
        private IInboxService _inboxService;

        public InboxController(IInboxService inboxService)
        {
            _inboxService = inboxService;            
        }

        public IEnumerable<MessageModel> GetAll()
        {
            return _inboxService.GetAllMessages();
        }

      [HttpGet("Inbox/Count")]
            public int GetInboxCount()
            {
                return _inboxService.GetMessageCount();
            }
}
路由中:

routes.MapHttpRoute("InboxEnquiryApi", "api/inbox/{action}", new { Controller = "Inbox" }, null, new WebApiAuthenticationHandler(GlobalConfiguration.Configuration));
当我点击“api/inbox/InquiryCount”的URL时,我得到以下错误:

**No HTTP resource was found that matches the request URI 'http://localhost:49597/api/inbox/enquirycount'**

Web api 2中支持属性路由


以下是详细信息:

此语法已在较新版本的webapi中更改。[HTTPPOST]现在是独立的,路由有一个新的属性,该属性采用路由url 例如


[Route(“GetRes/{month}”)]

它的GETAttribute而不是httpgetAttribute在编译时没有解析,您确定吗?是的,GETAttribute。使用AttributeRouting.Web.Http添加;(当然要拿到作品;)但是我现在得到了多个与请求错误匹配的操作。我以为这就是这个图书馆的全部意义。它们不能混合使用吗?您需要了解ASP.NET Web API路由在内部是如何工作的。它将url作为一种资源。AttributeRouting只是添加一个路由,类似于global.asax路由。它无法更改基础引擎。
**No HTTP resource was found that matches the request URI 'http://localhost:49597/api/inbox/enquirycount'**