Quantcast
Channel: htmlagilitypack Forum Rss Feed
Viewing all articles
Browse latest Browse all 655

New Post: Added Functionality - LoadUri

$
0
0
Hi,

Thanks for the great add-on-method, exactly what I was looking for...

I also needed to pass in credentials, so I'm posting the changes I did here as well...
        public void LoadUri(string uri)
        {
            LoadUri(uri, System.Net.CredentialCache.DefaultCredentials);
        }
        public void LoadUri(string uri, string userName, string password, string domain)
        {
            LoadUri(uri, new NetworkCredential(userName, password, domain));
        }
        public void LoadUri(string uri, ICredentials credentials)
        {
            if (uri == null)
                throw new ArgumentNullException("uri");
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
            request.Credentials = credentials;
            request.Timeout = 1 * 60 * 1000;
            
            using(HttpWebResponse response = (HttpWebResponse)request.GetResponse())
                using (StreamReader sr = new StreamReader(response.GetResponseStream()))
                {
                    Load(sr);
                }
        }

Viewing all articles
Browse latest Browse all 655

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>