0
我有這樣的代碼:ASP.Net窗體HttpClient的PostAsync沒有反應,沒有錯誤消息
using (var client = new HttpClient())
{
var values = new Dictionary<string, string>
{
{"site_id","001"},
{"apikey","abc01201az1024"},
{"trans_id","45364136"},
};
// Get the parameters in the url encoded format
var content = new FormUrlEncodedContent(values);
//Send request
var response = await client.PostAsync(url, content);
DataRoot<Transaction> outPut = null;
if (response.IsSuccessStatusCode)
{
//Get Response
var result = await response.Content.ReadAsStringAsync();
JsonConvert.DeserializeObject<DataRoot<Transaction>>(result);
}
return outPut;
}
在調試模式下在該階段,將碼不產生任何響應,沒有錯誤的代碼,但停止運行:
//Send request
var response = await client.PostAsync(url, content);
「停止跑步」是什麼意思?它是停在那條線上還是完全退出? – DavidG
在該行應用程序掛起幾秒鐘,然後停止。該代碼不會轉到下一行。 – Jmocke
但是你沒有對'response'對象做任何事情,你想要發生什麼? – DavidG