How do i access a website which needs UserID and Password, I need to capture the cookies so that i can send in another location and get some data.
My code is like this.the URL I have is h5.www5.PP.com/partnerportal/au/en
byte
[] ba = System.Text.Encoding.ASCII.GetBytes("userName=bsim&Password=Bimbed&submit=submit"); IS this correct?HttpWebRequest webRequest=(HttpWebRequest)HttpWebRequest.Create("h5.www5.PP.com/partnerportal/au/en);
webRequest.KeepAlive =
false;webRequest.UserAgent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)";
webRequest.Method = "POST";
webRequest.ContentType ="text/html";
webRequest.ContentLength = ba.Length;
System.IO.Stream requestStream = webRequest.GetRequestStream();
requestStream.Write(ba, 0, ba.Length);
requestStream.Flush();
requestStream.Close();
webRequest.AllowAutoRedirect =
false;WebResponse webResponse = (HttpWebResponse)webRequest.GetResponse();
return webResponse.Headers["Set-Cookie"];Questions: is the above code correct?
when passing username what wording should i user.
When i click on login it goes through this url
To this URL.
http://h5.www5.pp.com/partnerportal_s/au/en/start.swe?SWECmd=Login&SWEPL=1&SWETS=sc
Replies
Know the answer? Post it — somebody with the same question will find it here.