Method for Making a Simple Web Request





4.00/5 (6 votes)
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();
}