1

FrameWork : .Net Framework 4.7.2.

Web api project: After pull code from git (worked and compiled on a different local machine), and trying to build, getting:

**The type or namespace name 'ApiController' could not be found (are you missing a using directive or an assembly reference?)**

regarding all apiController inherited class attributes and keywords :ApiController, HttpPost, FromBody, etc.),

using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Web.Http;

namespace POC_Book_Api.Controllers
{
    public class MyController : ApiController
    {
        
        [HttpPost]
        public void Post([FromBody] SomeCollection items)

System.Web Assembly is referenced in the project References. Nuget Microsoft.AspNet.Api is installed and updated in the project.

What am I missing here ?

Guy E
  • 1,775
  • 2
  • 27
  • 55

2 Answers2

2

The solution was to reinstall (uninstall + install) the relevant packages. The problem was that while uninstalling it throught the Nuget package manager - it didn't actually uninstall it because other nuget packages was depending on it. I was aware of it only after doing it using the Package manager console. I unistalled all the dependencies - then the nuget itself and then install it again

Guy E
  • 1,775
  • 2
  • 27
  • 55
  • oh. Since I had made a very simple setup (with only a test class), it worked for me. Good you find out... make sense that nuget doesn't deinstall it, when there depandencies... – Christian Müller Jul 13 '20 at 12:07
1

Please try to reinstall the package via Package Management Console:

Install-Package Microsoft.AspNet.WebApi

Please ensure you have the correct project selected and Package Source is nuget.org:

enter image description here