c# - System.Net.WebClient fails weirdly -


I am trying to download some data from the examples of reporting services on our TFS server.
Given that code should be run on a computer that is not connected to a domain, I thought I would set myself credentials, no luck, an HTTP 401 unauthorized return was found. Okay, so I bowed down to the folder to see what was going on.

But when I got it - the call now went without a hold. So the authentication goes through with the engagement, but it fails without it. Is the webclient broken or am I missing here some depth?

  Private zero this works when the docsin () {WebClient wc = new WebClient (); Wc.Credentials = CredentialCache.DefaultNetworkCredentials; Wc.DownloadString ("http: // teamfoundationserver / report / ........"); // Works} Private Zero It Dotswart () {webclient wc = new webclient (); Wc.Credentials = New network credentials ("username", "password", "domain"); Wc.DownloadString ("http: // teamfoundationserver / report / ........"); // wH HTTP 401} / <>   

Take a look at this link:

I had a problem similar to you. I've just added one line and started working on it. Try it

  This dotswork from Private Zero () {WebClient wc = New WebClient (); Wc.Credentials = New network credentials ("username", "password", "domain"); // After adding the header it started working! Wc.Headers.Add (HttpRequestHeader.UserAgent, "Mozilla / 4.0 (compatible; MSIE 6.0; Windows NT 5.1)"); Wc.DownloadString ("http: // teamfoundationserver / report / ........"); // wows hitt 401}  

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -