Created
December 13, 2010 14:37
-
-
Save johnathan-sewell/739040 to your computer and use it in GitHub Desktop.
HttpWebRequest - read page into string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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