Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

missing Web API controller class template VS 2010

In VS 2010 WEB FORMS project, I used nuget "install-package Microsoft.aspnet.webapi".

PM> install-package Microsoft.aspnet.webapi Attempting to resolve dependency 'Microsoft.AspNet.WebApi.WebHost (≥ 4.0.20505.0)'. Attempting to resolve dependency 'Microsoft.Web.Infrastructure (≥ 1.0.0.0)'. Attempting to resolve dependency 'Microsoft.AspNet.WebApi.Core (≥ 4.0.20505.0)'. Attempting to resolve dependency 'Microsoft.AspNet.WebApi.Client (≥ 4.0.20505.0)'. Attempting to resolve dependency 'Microsoft.Net.Http (≥ 2.0.20505.0)'. Attempting to resolve dependency 'Newtonsoft.Json (≥ 4.5.1)'. 'Microsoft.AspNet.WebApi 4.0.20505.0' installed.

However, when I go to "Add new item...", under installed templates, "Web API Controller Class" is NOT available. What else do I need to install to make the template show up. I DO NOT have MVC4 installed, do I need it also before the template will show up?

enter image description here

like image 817
Robert4Real Avatar asked Feb 11 '26 15:02

Robert4Real


1 Answers

Nuget gives you only the assemblies required to run Web API.

To use MVC4 Web Api Visual Studio template you have to install MVC4 package from here - http://www.asp.net/web-api. Once that's installed, in the "create new project" wizard you'd have to choose MVC4 template, and in the next window you can choose Web API project.

Note, that this is not necessary if you don't explicitly need an MVC4 applications. You can use Web API with pretty much anything - MVC3, with Web Forms, with console apps, WPF apps.. It's not dependant in any way on MVC4.

like image 161
Filip W Avatar answered Feb 13 '26 08:02

Filip W



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!