Click here to Skip to main content
15,887,477 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi,

I'm trying to download the web page source code from a HTTPS URL, my code is as follows:
C#
System.Net.WebClient WC = new System.Net.WebClient();

           NetworkCredential Cred = new NetworkCredential();
           Cred.UserName = "user";
           Cred.Password = "pass";

           WC.Credentials = Cred;

           System.IO.Stream s = WC.OpenRead("https://xxxxxx/data.html");
           System.IO.StreamReader sr = new System.IO.StreamReader(s);
           string webpage = sr.ReadToEnd();

I get a 401 (unauthorized) exception, and i am 100% sure the credentials are correct, and work perfectly in my web browser for the file.

I have tested this code without the credentials, on a standard HTTP URL and it works fine.

Any ideas what I am doing wrong?

Thanks for any help
Posted
Updated 21-Jun-12 22:58pm
v2

1 solution

You can refer my solution mentioned at following link
VB.NET can't connect to a HTTPS Web Server[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900