In essence, it is to download the remote image Stream to the local device and display it with pictureBox.
With a cookie, you can identify it with the naked eye
The code is very simple.
The foreground is also a pictureBox control.
AutoLoginHelper autoLoginHelper = new AutoLoginHelper (Encoding. UTF8 );
CookieContainer cc = new CookieContainer ();
Stream stream = autoLoginHelper. GetImages ("http://passport.csdn.net/ShowExPwd.aspx%22,string.Empty,Encoding.UTF8,ref cc );
Image img = new Bitmap (stream );
This. pictureBox1.Image = img;
Public Stream GetImages (string url, string postData, Encoding encoding, ref CookieContainer cookieContainer)
{
Byte [] postByte = encoding. GetBytes (postData );
HttpWebRequest wr = System. Net. HttpWebRequest. Create (url) as HttpWebRequest;
Wr. CookieContainer = cookieContainer;
Wr. Method = "POST ";
Wr. ContentType = "application/x-www-form-urlencoded ";
Wr. userAgent = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; InfoPath.2 ;. net clr 2.0.50727 ;. net clr 3.0.04506.648 ;. net clr 3.5.21022; MS-RTC LM 8 ;. net clr 3.0.20.6.2152 ;. net clr 3.5.30729 )";
Wr. Referer = url;
Wr. CookieContainer = cookieContainer;
Wr. ContentLength = postByte. Length;
Stream sr = wr. GetRequestStream ();
Sr. Write (postByte, 0, postByte. Length );
Sr. Close ();
HttpWebResponse response = wr. GetResponse () as HttpWebResponse;
System. IO. Stream responseStream = response. GetResponseStream ();
Return responseStream;
}