它没有在服务器上返回FirstName。始终返回null。我无法理解它在做什么?
客户端代码
url = '/Home/RegisterByFacebook';
user = '{ FirstName: "firstName"}';
var userJson = $.toJSON(user);
// console.log(userJson);
$.ajax({
url: url,
type: 'POST',
data: userJson,
async: true,
dataType: 'Json',
contentType: 'application/json; charset=utf-8',
success: function (response) {
if (response == "true") {
window.location.href = "/search/index";
}
}
});
服务器端代码:
[HttpPost]
[AllowAnonymous]
public JsonResult RegisterByFacebook(string FirstName)
{
return Json("success", JsonRequestBehavior.AllowGet);
}
Inspecting Element向我展示了这个: