HttpWebRequest and HttpWebResponse greatly simplified http content retrial process. Code snippet below demonstrated how easy to use.
using System; using System.Text; using System.Net; using System.IO; static void Main(string[] args) { string webUrl = "http://www.google.com"; WebRequest req = WebRequest.Create(webUrl); req.Timeout = 10000; WebResponse resp = req.GetResponse(); StreamReader reader = new StreamReader(resp.GetResponseStream(), Encoding.ASCII); Console.WriteLine(reader.ReadToEnd()); resp.Close(); // Close the response to free resources. reader.Close(); } |
Simple and elegant. To look for more…Retrieving HTTP content in .NET