Problem with JsonResult exception

I have a controller action that returns a JsonResult and is consumed using a jquery ajax get request. Everything works fine on my machine, but when copying to the hosting at the factory, I get the following exceptions in the action of the last controller:

[AcceptVerbs(HttpVerbs.Get)]
public JsonResult Single(int UNIQUE_NO) {
  ...
  return Json(data, JsonRequestBehavior.AllowGet);  // < here exception is thrown
}

Method not found: 'System.Web.Mvc.JsonResult System.Web.Mvc.Controller.Json (System.Object, System.Web.Mvc.JsonRequestBehavior)'.

An exception occurs using ELHAM.

Platform: ASP.NET MVC 2 Beta p>

Dlls included in the application (Copy local: true): Microsoft.Web.Mvc, MvcContrib, MvcContrib.FluentHtml, MvcContrib.TestHelper, Rhino.Mocks, System.Web.Mvc, System.Web.Routing

What's going on here? What / Where should I look for this? (as mentioned above, I don't get this exception on my dev machine where the json result object is generated as expected and returned to the caller)

Here is the call stack (ELMAH):

System.MissingMethodException: : 'System.Web.Mvc.JsonResult System.Web.Mvc.Controller.Json(System.Object, System.Web.Mvc.JsonRequestBehavior)'.   NN_AccessToWeb_MVC2.Controllers.HomeController.Single(Int32 UNIQUE_NO)   lambda_method (ExecutionScope, ControllerBase, Object [])   System.Web.Mvc.ActionMethodDispatcher.Execute( ControllerBase, Object [])   System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary 2 parameters) at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary 2 )   System.Web.Mvc.ControllerActionInvoker. < > c__DisplayClassa.b__7()   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter( IActionFilter, ActionExecutingContext preContext, Func 1 continuation) at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClassa.<>c__DisplayClassc.<InvokeActionMethodWithFilters>b__9() at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList 1 , ActionDescriptor actionDescriptor, IDictionary`2)   System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName)

+3
2

JsonResult:

return new JsonResult {
    JsonRequestBehavior = JsonRequestBehavior.AllowGet,
    Data = /* you model goes here */,
    ContentType = "application/json",
    ContentEncoding = Encoding.UTF8
};
+2
return Json(data, "application/json", Encoding.UTF8, JsonRequestBehavior.AllowGet);
0

Source: https://habr.com/ru/post/1725046/


All Articles