这是一个真正的初学者问题,希望你能帮我快速回答。
当我调用JsonResult类型的动作时,视图呈现为原始Json而不是我创建的预期定义视图。
这就是我在浏览器中看到的所有内容:
[{"Name":"xx","Description":"xx","Address":"xx","Town":"xx","PostCode":"xx","Enabled":true,"pkId":1},{"Name":"xx","Description":"xx","Address":"xx","Town":"xx","PostCode":"xxx","Enabled":true,"pkId":3}]
这是我的行动:
public JsonResult SubmitFeedback()
{
PropertyInspectionContext context = new PropertyInspectionContext();
var prop = context.Property;
return Json(prop, JsonRequestBehavior.AllowGet);
}
谢谢,
答案 0 :(得分:0)
如果您已经创建了JsonResult(Json),那么返回JsonString。
如果你想View应该返回Html标记和模型组合,那么你应该返回查看结果。
public ActionResult SubmitFeedback()
{
PropertyInspectionContext context = new PropertyInspectionContext();
var prop = context.Property;
//return Json(prop, JsonRequestBehavior.AllowGet);
return View(your view name,prop);
}