When I create an HttpWebRequest, it seems to have the right uri to access the website (with the GET variables there too). But as soon as I run request.GetResp onse() the URL changes such that it no longer includes the GET variables and it uses that new uri for accessing the server. Anyone know what might be the problem?
Code:
string url = "http://internal.company.com?var1=x&var2=y"; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.Timeout = timeout; request.UserAgent = "UserAgentName"; request.Headers.Add("Accept-Encoding", "gzip, deflate"); request.UseDefaultCredentials = true; request.CookieContainer = new CookieContainer(); using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) { //Console.WriteLine(response.StatusDescription); using (Stream dataStream = GetStream(response)) { using (StreamReader reader = new StreamReader(dataStream, Encoding.UTF8)) { string data = reader.ReadToEnd(); //Console.WriteLine(data); return data; } } }
Comment