Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Net;
- using System.Net.Http;
- using System.Text;
- using System.Threading.Tasks;
- namespace GW2TPv2
- {
- class Class1
- {
- private HttpClient httpClient;
- private HttpClientHandler httpClientHandler;
- private CookieContainer cookieContainer;
- private Uri baseAddress;
- public Class1()
- {
- // First we set the base address
- baseAddress = new Uri("http://tradingpost-dfw-live.ncplatform.net");
- cookieContainer = new CookieContainer();
- cookieContainer.Add(baseAddress, new Cookie("s", "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX")); //add session id
- // "http://tradingpost-dfw-live.ncplatform.net"
- }
- //I call this in my Main()
- public async void request()
- {
- //Something isn't right in here?
- httpClientHandler = new HttpClientHandler()
- {
- CookieContainer = cookieContainer,
- UseCookies = false
- };
- using (httpClient = new HttpClient() { BaseAddress = baseAddress })
- {
- // More setup
- httpClient.MaxResponseContentBufferSize = 256000;
- httpClient.DefaultRequestHeaders.Add("user-agent", "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)");
- try
- {
- string response;
- HttpResponseMessage httpresponse = await httpClient.GetAsync("http://tradingpost-dfw-live.ncplatform.net");
- httpresponse.EnsureSuccessStatusCode();
- response = await httpresponse.Content.ReadAsStringAsync();
- Console.WriteLine(response);
- }
- catch (HttpRequestException hre)
- {
- Console.WriteLine(hre.ToString());
- }
- catch (Exception ex)
- {
- // For debugging
- Console.WriteLine(ex.ToString());
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement