-1
我不知道我在做什麼錯或改變了什麼。 我試圖發送JSON參數的MVC控制器磊1.1Netcore,JSON參數始終爲空
MVC控制器:
[HttpPost]
public JsonResult Test1(DepartmentDTO departmentDto, int testId)
{
return Json(departmentDto);
}
public partial class DepartmentDTO
{
public int DepartmentID { get; set; }
public string Description{ get; set; }
}
的Javascript POST:
var req = {
method: 'POST',
url: "/Department/Test1",
headers: {
'Content-Type': 'application/json;charset=utf-8'
},
data: JSON.stringify({
"departmentDto": { "DepartmentID": 1, "Description": "TEST" },
"testId": 1
}),
};
var promise = $http(req).then(function successCallback(response) {
if (response.data.departmentID == 0) {
alert("Wrong")
}
return response.data
}, function errorCallback(response) {
return { success: false, message: response.data };
});
所有參數都總是空:departmentDto & testId 謝謝你的幫助。
究竟是什麼問題? – Pointy
所有參數始終爲空。 –
所有參數* * what *? – Pointy