0
我希望能夠從我的控制器方法中讀取帖子變量。WebApi - 爲什麼我的post變量總是空?
目前,我有下面的代碼:
[HttpPost]
public IHttpActionResult BuildPartitions([FromBody]string PartitionBuildDate)
{
}
我用下面的代碼進行測試:
using (HttpClient httpClient = new HttpClient())
{
var values = new Dictionary<string, string>
{
{ "PartitionBuildDate", "24-May-2017" }
};
var content = new FormUrlEncodedContent(values);
var response = httpClient.PostAsync("http://localhost:55974/api/Controller/BuildPartitions", content);
var responseString = response.Result.Content;
}
網上看,這看起來是正確的發送和接收中的變量後C#,但是PartitionBuildDate變量始終爲空。