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