Mega Code Archive

 
Categories / C# Tutorial / Network
 

Use WebRequest and WebResponse to read a web page

using System; using System.Net; using System.IO; public class MainClass {    [STAThread]    public static void Main(string[] args)    {        string htmlUri = "http://www.rntsoft.com";        WebRequest requestHtml = WebRequest.Create(htmlUri);               WebResponse responseHtml = requestHtml.GetResponse();        // Read the text from the response stream.        using (StreamReader r = new StreamReader(responseHtml.GetResponseStream()))        {            Console.WriteLine( r.ReadToEnd());        }    }   } Java examples (example source code) Organized by topic ...