asp.net mvc 3 - JSON object passing back to view from controller in a mix application of MVC2 and MVC3 -
to give background, application mix application containing both aspx , razorview engine. have controller extension class,
public static class controllerextensions { public static viewresult razorview(this controller controller) { return razorview(controller, null, null); } public static viewresult razorview(this controller controller, object model) { return razorview(controller, null, model); } public static viewresult razorview(this controller controller, string viewname) { return razorview(controller, viewname, null); } public static viewresult razorview(this controller controller, string viewname, object model) { if (model != null) controller.viewdata.model = model; controller.viewbag._viewname = getviewname(controller, viewname); return new viewresult { viewname = "razorview", viewdata = controller.viewdata, tempdata = controller.tempdata }; } static string getviewname(controller controller, string viewname) { return !string.isnullorempty(viewname) ? viewname : controller.routedata.getrequiredstring("action"); } }
now controller need pass json object view.
i using piece of code form controller ,
return this.razorview (json(new { secho = param.secho, itotalrecords = data.summary.count, itotaldisplayrecords = data.summary.count, aadata = data.summary.tolist() }, jsonrequestbehavior.allowget)); errors out mentioning model item passed dictionary of type 'system.web.mvc.jsonresult', dictionary requires model item of type 'system.collections.generic.list`
please advise how can pass json object view ?
Comments
Post a Comment