Hi,
I would like to ask a question .
i need to write a code that connects to a site (for example
www.example.com)
but with a different host (for exapmple www.something.com) .
i read in msdn that i can not change the host with WebRequest.
i did a search in the web and i found in google groups a code that
seems like an answer .
http://groups.google.com/group/micro...768c733ad2f451
i tried to write this like "Dave P" suggested but i get and error "The
remote server returned an error: (502) Bad Gateway."
so i read more an i found that this error created because of proxy
error.
can some one please help me with this problem .
The Code i wrote is :
ASCIIEncoding encoding = new ASCIIEncoding();
string postData =
"ltmpl=login&continue=https://adwords.google.com/select/gaiaauth&followup=https://adwords.google.com/select/ga************************************************ ************************************************** ********************@compile.co.il&Passwd=moman81& null=Sign
in";
byte[] data = encoding.GetBytes(postData);
string url = "http://www.something.com";
HttpWebRequest myRequest =
(HttpWebRequest)WebRequest.Create(url);
myRequest.Proxy = new
WebProxy("http://www.example.com",false);
myRequest.Method = "POST";
myRequest.AllowAutoRedirect = true;
myRequest.ContentType =
"application/x-www-form-urlencoded";
myRequest.ContentLength = data.Length;
Stream newStream = myRequest.GetRequestStream();
// Send the data.
newStream.Write(data, 0, data.Length);
newStream.Close();
WebResponse myResponse = myRequest.GetResponse();
Stream ReceiveStream = myResponse.GetResponseStream();
Encoding encode =
System.Text.Encoding.GetEncoding("utf-8");
StreamReader readStream = new StreamReader(ReceiveStream,
encode);
string str = readStream.ReadToEnd();
readStream.Close();
myResponse.Close();