wpf写的http Post请求代码
var url = $" url地址";
Dictionary<string, string> dicForm = new Dictionary<string, string>();
//添加的两个参数
dicForm.Add("LoginName", "");
dicForm.Add("Password", "");
var httpcontext = new FormUrlEncodedContent(dicForm);
var request = new HttpRequestMessage(HttpMethod.Post,url)
{
Content = httpcontext
};
var httpmsg = await client.SendAsync(request);
if (httpmsg.IsSuccessStatusCode)
{
var content = await httpmsg.Content.ReadAsStringAsync();
T model= JsonHelper.ToJsonEntity<T>(content);
}