MVC 控制器参数为空
MVC Controller Parameter is null
这看起来很基础,但出于某种原因我无法让它工作。
Jquery..
$.post("/Member/Profile", "TESTDATA", function (result) {
console.log(result);
});
控制器
[HttpPost]
public JsonResult Profile(string model)
{
return Json(1);
}
我的 string model
参数为空,当我在它上面设置断点时我可以看到。我试过让它通过 json,尝试让它通过视图模型,尝试使用 ajax 和 Type/Method 作为 "POST".. 我的参数似乎总是以 null 形式出现.我做错了什么?!
try this
$.post("/Member/Profile", {model:'TESTDATA'}, function (result) {
console.log(result);
});
试试这个?
$.post("/Member/Profile", {model: 'TESTDATA'}, function (result) {
console.log(result);
});
这看起来很基础,但出于某种原因我无法让它工作。
Jquery..
$.post("/Member/Profile", "TESTDATA", function (result) {
console.log(result);
});
控制器
[HttpPost]
public JsonResult Profile(string model)
{
return Json(1);
}
我的 string model
参数为空,当我在它上面设置断点时我可以看到。我试过让它通过 json,尝试让它通过视图模型,尝试使用 ajax 和 Type/Method 作为 "POST".. 我的参数似乎总是以 null 形式出现.我做错了什么?!
try this
$.post("/Member/Profile", {model:'TESTDATA'}, function (result) {
console.log(result);
});
试试这个?
$.post("/Member/Profile", {model: 'TESTDATA'}, function (result) {
console.log(result);
});