string URLAuth =
"https://technet.rapaport.com/HTTP/Authenticate.aspx";
WebClient webClient =
new WebClient();
NameValueCollection formData =
new NameValueCollection();
formData["Username"] =
"myUser";
formData["Password"] =
"myPassword";
byte[] responseBytes = webClient.UploadValues(URLAuth,
"POST", formData);
string ResultAuth =
Encoding.UTF8.GetString(responseBytes);
string URL =
"GENERATED_URL_QUERY";
WebRequest webRequest =
WebRequest.Create(URL);
webRequest.Method =
"POST";
webRequest.ContentType =
"application/x-www-form-urlencoded";
webRequest.Headers.Add(System.Net.
HttpRequestHeader.AcceptEncoding,
"gzip");
Stream reqStream = webRequest.GetRequestStream();
string postData =
"ticket=" + ResultAuth;
byte[] postArray =
Encoding.ASCII.GetBytes(postData);
reqStream.Write(postArray, 0, postArray.Length);
reqStream.Close();
WebResponse webResponse = webRequest.GetResponse();
StreamReader str;
if (webResponse.Headers.Get(
"Content-Encoding") !=
null &&
webResponse.Headers.Get("Content-Encoding").ToLower() == "gzip")
{
str = new StreamReader(new GZipStream(webResponse.GetResponseStream(), CompressionMode.Decompress));
}
else
{
str = new StreamReader(webResponse.GetResponseStream());
}