.Net HttpClient form-data格式请求

1             var multipartFormDataContent = new MultipartFormDataContent();
2             multipartFormDataContent.Add(new StringContent("admin"), "UserName");
3             multipartFormDataContent.Add(new StringContent("123456"), "Password");
4             var client = _clientFactory.CreateClient();
5             var response = await client.PostAsync("http://localhost", multipartFormDataContent);
6             if (response.IsSuccessStatusCode)
7             {
8                 //do
9             }

 

posted @ 2018-10-30 22:22  anech  阅读(4085)  评论(0编辑  收藏  举报