download html

HttpWebRequest webrequest = (HttpWebRequest)HttpWebRequest.Create("http://www.baidu.com");
       HttpWebResponse webreponse = (HttpWebResponse)webrequest.GetResponse();
       Stream stream = webreponse.GetResponseStream();
       byte[] rsByte = new Byte[webreponse.ContentLength];  //save data in the stream
       try
       {
           stream.Read(rsByte, 0, (int)webreponse.ContentLength);
           string s = System.Text.Encoding.Default.GetString(rsByte, 0, rsByte.Length).ToString();
           Response.Write(s);
       }
       catch (Exception exp)
       {
           Response.Write(exp.ToString());
       }

你可能感兴趣的:(download)