The remote server returned an error: (401) Unauthorized RRS feed

  • Question

  • Hello Everybody,

    I'm using this code to get XmlDocument from url:

                using (WebClient wc = new WebClient())
                    wc.Credentials = new NetworkCredential("admin", "admin");
                    string xml = wc.DownloadString("");
                    XmlDocument tournamentsXML = new XmlDocument();
                    XmlNodeList TagList = tournamentsXML.GetElementsByTagName("TAG");
                    foreach (XmlNode node in TagList)
                        XmlElement TagElement = (XmlElement)node;
                        string TagID = TagElement.GetElementsByTagName("tagid")[0].InnerText;
                        string MAC = TagElement.GetElementsByTagName("mac")[0].InnerText;
                        Data.Add(new Tag(TagID,MAC));

    It's work fine,

    But when I change the link to ""
    it give me error message "The remote server returned an error: (401) Unauthorized."

    By the way when I copy past the same link "" to browser it retreive XML data exactly !!

    Please help me please :(


    • Moved by Jason Dot Wang Monday, March 25, 2013 9:25 AM Apache server is not Microsoft product
    Monday, March 18, 2013 6:17 AM


All replies

  • No any reply !!


    Monday, March 18, 2013 9:08 AM
  • Cut us some slack, it's in the middle of the night in the US.

    Are you SURE the credentials in your browser are the same as what you set up in the program?   401 errors indicate authentication problems.    Have you checked the configuration on that server?

    Monday, March 18, 2013 9:51 AM
  • I think you should ask this to your System Admin. 

    The IP address is located in your own network so your system admin should know 

    Otherwise try this microsoft forum



    Monday, March 18, 2013 10:45 AM
  • Yes I'm trying to open it on IE and Firefox, it's work probably :(


    Monday, March 18, 2013 11:09 AM
  • Use fiddler to see what exactly those browsers send to the server and simulate that in your code. There are all kinds of reasons that you may get a 401, for example some servers limit verbs to Get or Put.

    Visual C++ MVP

    Monday, March 18, 2013 9:19 PM
  • Please any other help ,,,


    Tuesday, March 19, 2013 6:29 AM
  • Hi Shakatra,

      Welcome to MSDN Forum Support.

      Please take a look at Sheng Jiang 蒋晟's suggestions,his mentioned kb article has listed the detailed scenario about (401) Unauthorized.

    Jason Wang [MSFT]
    MSDN Community Support | Feedback to us

    Thursday, March 21, 2013 4:43 AM
  • But the server is Apache not IIS


    Thursday, March 21, 2013 6:43 AM
  • Hi Shakatra,

      Welcome to MSDN Forum Support.

      If your problem doesn't use the Microsoft technique or its related product, I am sorry that I can't support you due to its outside of the scope we should do. Hope you understand us. Furthermore, we need to move your thread to Off-topic.

    Jason Wang [MSFT]
    MSDN Community Support | Feedback to us

    • Proposed as answer by Yasir Kamal Wednesday, June 12, 2013 12:39 PM
    • Unproposed as answer by Yasir Kamal Wednesday, June 12, 2013 12:40 PM
    Monday, March 25, 2013 9:24 AM