简体   繁体   中英

web api Route attribute not found

I need to implement a Method in my web service, which is available by a defined route. So I used the Route attribute like this:

    [Route("api/New")]
    public void CreateNew(int id)
    {
        //Do stuff
    }

But VS2013 says that the namespace "Route" can't be found.

I guess this can be solved by installing a nuget package.

Can anybody help?

属性路由在ASP.NET MVC 5或更高版本中是本机的,并且ASP.NET Web API 2.检查您的MVC版本它应该高于4。

  1. Install-Package AttributeRouting (for MVC)

  2. Install-Package AttributeRouting.WebApi (for Web API)

  3. Install-Package AttributeRouting.WebApi.Hosted (for self-hosted Web API)

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM