.net在Controller里的方法添加[HttpGet]和[HttpPost]

前端用post过来,Controller就要用[HttpPost],前端用get,Controller就要用[HttpGet],或者不管前端用什么,Controller都不加这些。

 

前端用post

$.ajax({
url: "/CommRecord/LockSendESMS",
type: "post",
data: {
id: data.ID,
isLock: isLock
},
success: function (data) {
}
});

 

 

Controller就要用[HttpPost]

[HttpPost]
public ActionResult LockSendESMS()
{
var sendSourceList = this.commRecordService.GetSendSource();

var list = (from n in sendSourceList
select new
{
DetailCode = n.ID,
DetailValue = n.DetailValue
}).ToList();

return Json(new { status = 1, data = list }, JsonRequestBehavior.AllowGet);
}

posted @ 2016-10-13 11:18  啊木Blue  阅读(592)  评论(0编辑  收藏  举报