需要Json方法返回一个View或PartialView,... [英] Need Json method to return a View or PartialView,...
问题描述
您好,朋友们可以请我为我的问题提供解决方案吗,...
我正在开发mvc3剃须刀应用程序,
我有myaccount详细信息页面,其中包含不同的详细信息块,例如
名称:在此块下,名字,姓氏
地址:地址1,2,城市,邮编,...
许可证:编号,有效期,签发国家..
所以每当我编辑任何块时,我都不希望页面刷新,所以使用jquery,ajax和json方法,但是,我的问题是
Hi frnds can any one please advice me a solution to my problem,...
i''m working on mvc3 razor apps,
i have myaccount details page which consists of different blocks of details like,
Name: under this block, first name, last name
address: address 1,2,city state, zip,...
license: number,expiry,issue country..
so whenever i edit any block i don''t want page to getting refresh,so using jquery, ajax and json methods but, my problem is
[JsonException]
public JsonResult AccountDetailsUpdate(MyDetailsModel mydetailsmodel)
{
return View("viewname");
}
但它引发了我错误,无法将JsonResult转换为ViewResult
我想从json方法返回视图,我们如何使其变为
but it throws me error, unable to convert JsonResult to ViewResult
i want to return to a view from json method, how can we make it
推荐答案
您正在返回视图.那不是JsonResult.错误是告诉您返回Json,因为您说过会. 此 [
You''re returning a view. That is not a JsonResult. The error is telling you to return Json, because you said you would. This[^] shows how to return Json, the short version is
return Json(xxx)
where xxx can be a list, I usually end up returning an anonymous class like return Json(new { MyResult = true, MyValue = myVar } );, etc.
这篇关于需要Json方法返回一个View或PartialView,...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!