Skip to content

Instantly share code, notes, and snippets.

@johnathan-sewell
Created December 13, 2010 14:37
Show Gist options
  • Save johnathan-sewell/739040 to your computer and use it in GitHub Desktop.
Save johnathan-sewell/739040 to your computer and use it in GitHub Desktop.
HttpWebRequest - read page into string
public static string GetPageAsString(Uri address)
{
var result = "";
var request = WebRequest.Create(address) as HttpWebRequest;
using (var response = request.GetResponse() as HttpWebResponse)
{
var reader = new StreamReader(response.GetResponseStream());
result = reader.ReadToEnd();
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment