"The type or namespace name 'Route' could not be found" using "attribute routing" "The type or namespace name 'Route' could not be found" using "attribute routing" asp.net asp.net

"The type or namespace name 'Route' could not be found" using "attribute routing"


This comment from Vedran Mandić solved the problem for me. I'm re-posting it here because I think it should be the answer (or at least a answer).

I did an 'Update-Package Microsoft.AspNet.WebApi.WebHost -reinstall' and it worked. Funny this happens after getting the latest version on different PCs from TFS. I guess this happens because of nuget packages not working properly with the versioning system


Attribute Routing is native in ASP.NET MVC 5, or later, and ASP.NET Web API 2.

For previous versions you can use one of the packages from the AttributeRouting project that allows to use attribute routing in previous version of ASP.NET MVC, and Web API. The availabe nuget packages are:

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

Please, be aware that the namespaces of attribute routing are different for each version, so you must review the project soruces code, or browse the .dll included by the installed package, to find out the right namespace, and change your using accordingly. For example:

using AttributeRouting.Web.Http;


In my case, in web api project there were two using references:

using System.Web.Http;using System.Web.Mvc; 

As soon as I removed System.Web.Mvc, the error was gone.