Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 602
L C Avatar asked Apr 24 '15 08:04

L C


2 Answers

Attribute Routing is native in ASP.NET MVC 5, or later, and ASP.NET Web API 2. check your MVC version it should be above the 4.

like image 91
Jaimin Soni Avatar answered Nov 15 '22 17:11

Jaimin Soni


  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)

like image 3
BhasvatKumar Avatar answered Nov 15 '22 17:11

BhasvatKumar