0
中請求數據MVC asp.net核心的WebAPI服務呼叫傳遞空值
JSON數據
我不知道,爲什麼它傳遞null值API?
更新1
這裏是我的Web用戶界面的操作代碼
const string URLPREFIX = "api/account";
[HttpPost]
public async Task<IActionResult> Login(LoginModel loginModel)
{
var loginFlag = false;
HttpResponseMessage response1 = await ServiceCall<LoginModel>.postData(URLPREFIX + "/authenticate",loginModel);
if (response1.IsSuccessStatusCode)
{
loginFlag = await response1.Content.ReadAsAsync<bool>();
}
if (loginFlag)
{
return RedirectToAction("Index","Home");
}
else
{
return View();
}
}
更新2
public class LoginModel
{
[Required]
[Display(Name = "Username")]
public string Username { get; set; }
[Required]
[DataType(DataType.Password)]
[Display(Name = "Password")]
public string Password { get; set; }
}
任何嘗試和回覆,謝謝
你能顯示你的webapi請求代碼嗎? –
你能更具體嗎? – RajSan
哪裏是loginmodel – CodingYoshi