How to output Json string as JsonResult in MVC4?

后端 未结 2 1526
無奈伤痛
無奈伤痛 2020-12-05 10:01

This seems so simple I must be over-thinking it.

TL;DR;

How can I modify the code below to return the json object contained in the string

相关标签:
2条回答
  • 2020-12-05 10:32

    The whole point of the Json() helper method is to serialize as JSON.

    If you want to return raw content, do that directly:

    return Content(jsonString, "application/json");
    
    0 讨论(0)
  • 2020-12-05 10:43
    public ActionResult Test()
    {
      return Json(new { success = true }, JsonRequestBehavior.AllowGet);
    }
    
    0 讨论(0)
提交回复
热议问题