Hi,
I am trying to download a image that is generated by PHP using
HttpWebRequest, I believe the server uses cookies to generate the image, but
I keep getting the error image from the server.
Can anyone help?
The code I am using is :-
Uri myUrl = new
Uri("http://www.kingsofchao s.com/recruit.php?uni qid=84y75898");
HttpWebRequest myReq = (HttpWebRequest ) WebRequest.Crea te(myUrl);
myReq.CookieCon tainer = new CookieContainer ();
myReq.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET
CLR 1.0.3705)";
myReq.KeepAlive = true;
HttpWebResponse myResponse = (HttpWebRespons e) myReq.GetRespon se();
Console.WriteLi ne("\nThe HttpHeaders are \n\n\tName\t\tV alue\n{0}",
myResponse.Head ers);
string mySession = myResponse.Head ers["Set-Cookie"];
myResponse.Clos e();
myReq = (HttpWebRequest )
WebRequest.Crea te("http://www.kingsofchao s.com/imageclick.php" );
myReq.CookieCon tainer = new CookieContainer ();
myReq.Headers["Cookie"] = mySession;
Console.WriteLi ne("\nThe HttpHeaders are \n\n\tName\t\tV alue\n{0}",
myReq.Headers);
myReq.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET
CLR 1.0.3705)";
myReq.KeepAlive = true;
myResponse = (HttpWebRespons e) myReq.GetRespon se();
pictureBox1.Ima ge = Image.FromStrea m(myResponse.Ge tResponseStream ());
pictureBox1.Siz e = pictureBox1.Ima ge.Size;
myResponse.Clos e();
Thanks in advance
Adam