I have a normal ASP.NET MVC project (not Web API). Here I created a new folder inside my controllers called "api", as I want to create a simple api.
I then create the following class:
public class OfficeProductController : ApiController
{
[HttpPost]
public JsonResult Create(OfficeProductViewModel model)
{
var obj = new OfficeProductViewModel();
return Json(obj);
}
}
Here I get two problems:
- HttpPost: results in "Ambiguous reference" (between the Http.HttpPostAttribute and the Mvc.HttpPostAttribute)
- Json() isn't recognized. It simply gives me a "cannot resolve symbol Json"
If I remember correctly, this would work in a web api project.
What am I doing wrong? Something I need to add?