I have controller action which returns JsonResult and is consumed by jquery ajax get request. All works well on my well my dev machine but when copied on production hosting I get below exception on last line controller action:
[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)'.
Exception is being captured by ELHAM.
Platform: ASP.NET MVC 2 Beta
Dlls included with app (Copy local : true): Microsoft.Web.Mvc, MvcContrib, MvcContrib.FluentHtml, MvcContrib.TestHelper, Rhino.Mocks, System.Web.Mvc, System.Web.Routing
What is going on here? What/Where should I be looking for this? (as mentioned above I dont get this exception on my dev machine where json result object is generated as expected and returned to caller)
Here is call stack (ELMAH):
System.MissingMethodException: Method not found: 'System.Web.Mvc.JsonResult System.Web.Mvc.Controller.Json(System.Object, System.Web.Mvc.JsonRequestBehavior)'.
at NN_AccessToWeb_MVC2.Controllers.HomeController.Single(Int32 UNIQUE_NO)
at lambda_method(ExecutionScope , ControllerBase , Object[] )
at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters)
at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext c开发者_StackOverflow社区ontrollerContext, IDictionary2 parameters)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary
2 parameters)
at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClassa.b__7()
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func1 continuation)
at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClassa.<>c__DisplayClassc.<InvokeActionMethodWithFilters>b__9()
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList
1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
at System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName)
Try returning a new JsonResult
:
return new JsonResult {
JsonRequestBehavior = JsonRequestBehavior.AllowGet,
Data = /* you model goes here */,
ContentType = "application/json",
ContentEncoding = Encoding.UTF8
};
return Json(data, "application/json", Encoding.UTF8, JsonRequestBehavior.AllowGet);
精彩评论