我想發送兩個參數get和post到服務上的方法沒有模型,但它總是空的。我怎麼解決這個問題?此外,這個問題的邏輯原因是什麼?代碼如下,我遇到問題;WebApi GET和多個POST參數無模型總是空
[HttpGet]
public Result GetUser(string userId)
{
using (DataContext dc = new DataContext())
{
return dc.GetUser(userId);
}
}
[HttpPost]
public Result CreateUser([FromBody]string firstname, [FromBody]string lastname)
{
using (DataContext dc = new DataContext())
{
return dc.CreateUser(firstname, lastname);
}
}
你是什麼意思,你試圖沒有模型做到這一點? – Luke
你也可以發佈你的ajax請求調用,沒有它你的問題是不完整的。 – Yasser