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);

猜你喜欢

转载自www.cnblogs.com/stone2012/p/11444869.html