Hi,
I was using the WebClient class (to do some screen scraping) and I was forced to change to the HttpWebRequest/Response because I needed control over the http headers. I am having two problems that have got me stumped. I am using Visual Studio 2003, Framework 1.1.
1) Even though I set HttpWebRequest.KeepAlive=true, I am not getting a connection header with keep-alive as the value. According to everything I have read this should work.
2) My Request stream is not being sent to the destination server.
Any help would be appreciated, here is the code:
HttpWebRequest Step2Request = (HttpWebRequest)WebRequest.Create(Global.LoginHost HTTP);
Step2Request.Method="POST";
Step2Request.KeepAlive=true;
Step2Request.Accept="image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*";
Step2Request.Referer=Global.LoginHostHTTP;
Step2Request.UserAgent="Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.1)";
Step2Request.ContentType="application/x-www-form-urlencoded";
Step2Request.Headers.Add("UA-CPU: x86");
Step2Request.Headers.Add("Accept-Encoding: gzip, deflate");
Step2Request.Headers.Add("Accept-Language: en-us");
Step2Request.Headers.Add("Cache-Control: no-cache");
byte [] Step2UploadData=CommonMethodsClass.convertstringto byte(querystring);
int Step2DataLength=Step2UploadData.Length;
Step2Request.ContentLength=Step2DataLength;
Stream REQstream = Step2Request.GetRequestStream();
HttpWebResponse Step2Response = (HttpWebResponse)Step2Request.GetResponse();
Stream RESstream = Step2Response.GetResponseStream();
REQstream.Write(Step2UploadData,0,Step2DataLength) ;
REQstream.Close();
Thanks,
Nick