1、Action方法既没加HttpGet,又没加HttpPost
public ActionResult Edit(string code,string name)
{
//表示既接收get请求,也接收post请求
}
post请求action
var ss = { "code": "aa",“name”:"张三"};
$.ajax({
type: 'post', url: '/User/UserInfo/Edit', data: ss, success: function (d) {
{
if (d == "OK") {
//dosth
}
else {
//dosth
}
};
}
});
get请求action
var ss = { "code": "aa",“name”:"张三"};
$.ajax({
type: 'get', url: '/User/UserInfo/Edit', data: ss, success: function (d) {
{
if (d == "OK") {
//dosth
}
else {
//dosth
}
};
}
});
二、Action标记为HttpGet或HttpPost
此种情况客户端只能对应的请求方式进行请求,否则会报404错误
Failed to load resource: the server responded with a status of 404 (Not Found)