我这个问题了一个星期挣扎。 我必须使用API在Windows Store应用摘要式身份验证,但是当我使用这个代码,我在这行代码得到System.ArgumentNullException:
HttpHandler.Credentials = credCache;
下面是代码其余部分:
var credCache = new CredentialCache();
credCache.Add(new Uri("https://myserverIP/api"),"Digest",new NetworkCredential("mylogin", "mypassword") );
var HttpHandler = new HttpClientHandler();
HttpHandler.Credentials = credCache;
var httpClient = new HttpClient(HttpHandler);
var answer = await httpClient.GetAsync(new Uri("https://myserverIP/api/?function=someKindOfFunction"));
answer.EnsureSuccessStatusCode();
我究竟做错了什么?