This project has moved. For the latest updates, please go here.

Internet service where proxy and authentication required

Topics: Developer Forum, User Forum
Mar 25, 2010 at 9:46 AM

I was searching internet to find how to use HtmlWeb.Load() method under internet service where proxy server and authentication is required.  But didn't find the required information. Later on i've figured out the code and now my application is working find under secured corporate internet where proxy and authentication is must. Below is the code for those who might face the similar situation.

            HtmlWeb web = new HtmlWeb();
            web.UseCookies = true;
            System.Net.WebProxy wp=new System.Net.WebProxy();
            NetworkCredential nc = (NetworkCredential)CredentialCache.DefaultCredentials;
            HtmlDocument doc = web.Load("","GET", wp,nc);
            //Set the XPath query
            string path = @"//td[@bgcolor='#FFF3E9']";
            // Get all columns in the document
            HtmlNodeCollection cols = doc.DocumentNode.SelectNodes(path);

Hope this will be useful for you.


Jul 29, 2010 at 4:19 AM
Dear shamim078 I have created a project to get Html in a authenticated web page, and I code like you, But the html I get ( in "doc" object) is wrong, it is a message alert me must be login and response to login page. Can you help me. I want to get html of this adress: Thanks for you time.
Aug 12, 2010 at 8:27 AM

hoc sinh tgt >>>> It's different things - you need to POST username password and store session in cookies... I would advise to use httpwebrequest/httpwebresponse and then parse resulting html with htmlagilitypack.