问题
The question explains it all but here is some more info. I am trying to use 4sq api with C# and need to send username password pair in every request. The API documentations says that "curl -u user:pass" does the job but how can I do it with WebClient? Don't have time to inspect the traffic, maybe someone knows about it...
WebClient.Credential doesn't work by the way.
Thanks.
回答1:
This is the solution:
webRequest.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(authbytes));
authBytes is the password converted to byte array.
回答2:
Try using a CredentialCache
来源:https://stackoverflow.com/questions/3996771/curl-u-equivalent-in-net-webclient-class