I've set up this test method on a controller to strip out any complication to it. Based off of all the results I've found from searching this should work. I'm not sure what I'm missing here.
public JsonResult test()
{
return Json(new { id = 1 });
}
This is the error I get.
Cannot implicitly convert type 'System.Web.Http.Results.JsonResult' to 'System.Web.Mvc.JsonResult'
Json(object data)
method that returns desiredSystem.Web.Mvc.JsonResult
is protected method ofSystem.Web.Mvc.Controller
. You need to inherit from Controller class to be able to use that. If your controller inherits from (eg) ApiController (as in my case;-) you are usingJson<T>(T content)
method that returnsSystem.Web.Http.Results.JsonResult<T>
... – Idola