Code
/// <Summary>
/// Obtain the webpage Verification Code
/// </Summary>
/// <Param name = "server"> server address </param>
/// <Param name = "url"> webpage address </param>
/// <Param name = "byterequest"> byte array, storing image bytes </param>
/// <Param name = "cookie"> the temporary sessionid (temporary cookie value) that the website assigns to the customer is not a real cookie </param>
/// <Param name = "Header"> </param>
/// <Returns> binary array of the image </returns>
Public static byte [] gethtmlbytes (string server, string URL, byte [] byterequest, string cookie, out string header)
{
Long contentlength;
Httpwebrequest;
Httpwebresponse webresponse;
Stream getstream;
Httpwebrequest = (httpwebrequest) httpwebrequest. Create (URL );
Cookiecontainer CO = new cookiecontainer ();
CO. setcookies (New uri (server), cookie );
Httpwebrequest. cookiecontainer = Co;
Httpwebrequest. contenttype = "application/X-WWW-form-urlencoded ";
Httpwebrequest. method = "Post ";
Httpwebrequest. contentlength = byterequest. length;
Stream stream;
Stream = httpwebrequest. getrequeststream ();
Stream. Write (byterequest, 0, byterequest. Length );
Stream. Close ();
Webresponse = (httpwebresponse) httpwebrequest. getresponse ();
Header = webresponse. headers. tostring ();
Getstream = webresponse. getresponsestream ();
Contentlength = webresponse. contentlength;
Byte [] outbytes = new byte [contentlength];
Outbytes = readfully (getstream );
Getstream. Close ();
Return outbytes;
}