401 unauthorized error RRS feed

  • Question

  •             string url, strXML;

                X509Certificate2 certificate = new X509Certificate2(CERTIFICATE);
                X509Store store = new X509Store(StoreName.TrustedPublisher, StoreLocation.LocalMachine);

                WebClient wc = new WebClient();

                url = @"https://www.vitaminshield.com/xxxxxxxxxx/select.php";
                Uri address = new Uri("https://www.vitaminshield.com/xxxxxxxxxx/select.php");
                NetworkCredential nc = new NetworkCredential("xxxxxxxxxxxxx", "xxxxxxxxxxx");
                wc.Credentials = nc;
                wc.BaseAddress = address.ToString(); //url did not work here either
                wc.DownloadFile(url, PATH + "\\Select1.xml");

                XmlDocument myXMLDocument = new XmlDocument();

     It blows up on the XML Document Load statement.  We have VS 2010, Windows 7.  Changing password to Secure password did not work.  XML header info only is being written to file Select1.xml
    Wednesday, July 29, 2015 8:28 PM


All replies

  • 401 means that the credentials you are supplying can't log into the computer host computer and access the resources.  

    You can see 401 errors in the Windows O/S Security Audit logs when Login Security Auditing is enabled on the O/S that is hosting the remote resource.

    Wednesday, July 29, 2015 8:38 PM
  • If you hosted the IIS your own then check your certificate. If you url is hosted by other then you need to check with them. https you definitely have a certificate somewhere.

    You need a detail logging to trace this.



    Wednesday, July 29, 2015 11:43 PM
  • Hi Alexander,

    The 401 Unauthorized error is an HTTP status code that means the page you were trying to access can not be loaded until you first log on with a valid user ID and password. If you have just logged on and received the 401 Unauthorized error, it means that the credentials you entered were invalid for some reason.

    Without your real scenarios, I've searched some similar issues related yours. Please refer to the following blogs to Fix the 401 Unauthorized Error

    >>Reporting Services HTTP 401 (Unauthorized) - Host Headers require your attention


    >>HOWTO: Diagnose 401.x HTTP errors on IIS


    Best regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Edited by Kristin Xie Thursday, July 30, 2015 8:48 AM
    • Marked as answer by Kristin Xie Friday, August 7, 2015 10:00 AM
    Thursday, July 30, 2015 8:45 AM