How can i fix this?
The reason is that you do not inherit from Controller , but from ApiController , where the first one has Json(object o) as the method in it of the base class, but this does not really matter, since there is a fundamental problem with your approach.
ApiController , which is used with WebAPI, is not intended to return an ActionResult , which is a concept owned by MVC. Instead, you simply return your POCO and let the WebAPI framework handle the serialization for you:
public object CreateAccount(CollaborateurModel item) { // Do stuff: if (result.Result.Succeeded) { return new { Success = true } } else { return new { Success = false, ErrorMessage = "error" }; } }
You can set the configuration
source share