ASP.Net MVC action 同时支持Get的方法

方法一:

在action方法 上加 AcceptVerbs标签,

示例:

[AcceptVerbs(HttpVerbs.Get | HttpVerbs.Post)]

public ActionResult Index()

 

方法二:

 

控制器代码

在action方法返回json数据时,添加JsonRequestBehavior.AllowGet参数,

示例:

  return Json(new { result = 1, message = "消息内容" }, JsonRequestBehavior.AllowGet);

 

posted @ 2019-09-02 09:46  stone2012  阅读(315)  评论(0编辑  收藏  举报