【发布时间】:2015-05-14 14:57:06
【问题描述】:
我为这个问题苦苦挣扎了一周。 我必须在 Windows 应用商店应用程序中使用带有摘要式身份验证的 API,但是当我使用此代码时,我在这行代码中得到 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();
我做错了什么?
【问题讨论】:
-
我将那个确切的代码复制到一个项目中,它工作正常(当然
GetAsync由于无效的 URI 而失败)。 -
好吧,我现在用的是 VS 2013 而不是 2015RC,它现在可以工作了。 :)
标签: c# windows-phone windows-store-apps dotnet-httpclient