- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
var handler = new HttpClientHandler
{
Proxy = usingProxy ? new WebProxy(proxyURI) : null,
UseProxy = usingProxy,
UseCookies = true,
CookieContainer = new CookieContainer()
};
if (session != null)
{
handler.CookieContainer.Add(new Uri(URL), new Cookie("PHPSESSID", session));
}
using (var client = new HttpClient(handler))
{
var content = new FormUrlEncodedContent(postParams);
var responseTask = client.PostAsync(url, content);
responseTask.Wait();
var responseStringTask = responseTask.Result.Content.ReadAsStringAsync();
responseStringTask.Wait();
var cookies = handler.CookieContainer.GetCookies(new Uri(URL));
session = cookies["PHPSESSID"].Value;
return responseStringTask.Result;
}