ASP.NET MVC 2.0 JsonRequestBehavior Global Setting

前端 未结 6 882
轻奢々
轻奢々 2021-02-02 06:50

ASP.NET MVC 2.0 will now, by default, throw an exception when an action attempts to return JSON in response to a GET request. I know this can be overridden on a method by method

6条回答
  •  醉梦人生
    2021-02-02 07:29

    MVC 2 block Json for GET requests for security reasons. If you want to override that behavior, check out the overload for Json that accepts a JsonRequestBehavior parameter.

    public ActionResult Index()
    
    {
    
       return Json(data, JsonRequestBehavior.AllowGet)
    
    }
    

提交回复
热议问题