第一个问题的答案是允许Json在GET中工作。杰森通常只在一个职位上工作。通过在控制器中使用以下return方法(使用您的return语句之一),可以在GET中允许Json。
return Json(new { comments = "none" }, JsonRequestBehavior.AllowGet)编辑: 您也可以返回,
JsonResult而不是
ActionResult如下所示。
public ActionResult GetComments(string blog_id, int page_size, int page_no) { try { List<Comment> comments = ReadCommentsFromDB(); // Assuming that Comments will be an empty list if there are no data return Json(comments, JsonRequestBehavior.AllowGet) } catch (Exception ex) { return Json(new { comments = ex.ToString() }, JsonRequestBehavior.AllowGet)); }}


