Skip to content

Instantly share code, notes, and snippets.

@premchandpl
Created November 24, 2014 14:01
public static string GetHtmlSource(string siteUrl, ICredentials credentials, CookieContainer cc)
{
string resourceUrl = siteUrl;
HttpWebRequest wreq = HttpWebRequest.Create(resourceUrl) as HttpWebRequest;
wreq.Credentials = credentials;
wreq.CookieContainer = cc;
wreq.Method = "POST";
wreq.UserAgent = HtmlControlConstants.USERAGENT;
wreq.ContentLength = 0;
wreq.ContentType = HtmlControlConstants.CONTENTTYPE;
string result;
WebResponse wresp = wreq.GetResponse();
using (StreamReader sr = new StreamReader(wresp.GetResponseStream()))
{
result = sr.ReadToEnd();
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment