Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Method for Making a Simple Web Request

0.00/5 (No votes)
26 Feb 2012 1  
A method for getting the response from a web request made to the specified URL.
A method for getting the response from a web request made to the specified URL:
public static string makeWebRequest(string host)
{
    var request = (HttpWebRequest)WebRequest.Create(new Uri(host));

    var response = (HttpWebResponse)request.GetResponse();

    Stream dataStream = response.GetResponseStream();
    StreamReader dataread = new StreamReader(dataStream);
    return dataread.ReadToEnd();
}

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here