Why is JsonRequestBehavior needed?

后端 未结 5 1136
[愿得一人]
[愿得一人] 2020-11-22 05:27

Why is Json Request Behavior needed?

If I want to restrict the HttpGet requests to my action I can decorate the action with the [Http

5条回答
  •  情歌与酒
    2020-11-22 06:09

    By default Jsonresult "Deny get"

    Suppose if we have method like below

      [HttpPost]
     public JsonResult amc(){}
    

    By default it "Deny Get".

    In the below method

    public JsonResult amc(){}
    

    When you need to allowget or use get ,we have to use JsonRequestBehavior.AllowGet.

    public JsonResult amc()
    {
     return Json(new Modle.JsonResponseData { Status = flag, Message = msg, Html = html }, JsonRequestBehavior.AllowGet);
    }
    

提交回复
热议问题