Downloading from HTTPS

This is a discussion on Downloading from HTTPS within the C# Programming forums, part of the General Programming Boards category; Hi, I'm trying to download the web page source code from a HTTPS URL, my code is as follows: Code: ...

  1. #1
    Registered User (TNT)'s Avatar
    Join Date
    Aug 2001
    Location
    UK
    Posts
    339

    Downloading from HTTPS

    Hi,

    I'm trying to download the web page source code from a HTTPS URL, my code is as follows:

    Code:
                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
    Jack
    TNT
    You Can Stop Me, But You Cant Stop Us All

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by (TNT)
    Any ideas what I am doing wrong?
    You mean other than posting C++ code on the C board?


    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Registered User (TNT)'s Avatar
    Join Date
    Aug 2001
    Location
    UK
    Posts
    339
    Woops sorry, please could a mod move to C#
    TNT
    You Can Stop Me, But You Cant Stop Us All

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,752
    Moved
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Downloading OpenGL - cannot find anywhere?
    By Jake.c in forum Game Programming
    Replies: 10
    Last Post: 03-01-2009, 10:48 AM
  2. sending https request
    By sreenu_daram in forum Networking/Device Communication
    Replies: 1
    Last Post: 08-05-2006, 10:08 AM
  3. action whilst downloading
    By eth0 in forum C Programming
    Replies: 5
    Last Post: 05-05-2005, 04:58 AM
  4. Downloading iso's in binary vs. ASCII
    By windoze victim in forum Tech Board
    Replies: 5
    Last Post: 12-02-2002, 07:51 AM
  5. Problems downloading mandrake
    By face_master in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 10-23-2002, 06:02 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21