Access the Internet : HttpWebRequest « Network « C# / CSharp Tutorial






using System; 
using System.Net; 
using System.IO; 
 
class MainClass {  
  public static void Main() { 
    int ch; 
 
    HttpWebRequest req = (HttpWebRequest) WebRequest.Create("http://www.java2s.com"); 
 
    HttpWebResponse resp = (HttpWebResponse) req.GetResponse(); 
 
    Stream istrm = resp.GetResponseStream(); 
 
    for(int i=1; ; i++) { 
      ch =  istrm.ReadByte(); 
      if(ch == -1) 
         break; 
      Console.Write((char) ch); 
    } 
 
    resp.Close(); 
  } 
}


     Java examples (example source code) Organized by topic 
...
...








33.22.HttpWebRequest
33.22.1.Examine the headers
33.22.2.Access the Internet