System.Net.WebClient fails weirdly

前端 未结 4 862
梦谈多话
梦谈多话 2021-02-19 18:29

I am trying to download some data from the reporting services instance on our TFS server.
Given that the code should run on a computer that is not domain-joined, I figured t

4条回答
  •  走了就别回头了
    2021-02-19 18:49

    I was able to get around this error by using a CredentialCache object, as follows:

    WebClient wc = new WebClient();
    CredentialCache credCache = new CredentialCache();
    credCache.Add(new Uri("http://mydomain.com/"), "Basic",
    new NetworkCredential("username", "password"));
    
    wc.Credentials = credCache;
    
    wc.DownloadString(queryString));
    

提交回复
热议问题