HttpRequestMessage and Digest Authentication

梦想与她 提交于 2019-12-04 00:59:53

问题


Is there any built-in function to associate a digest authentication with an HttpRequestMessage in winrt ? Or do I have to use an other class in order to perfom this task ?

Thanks.


回答1:


I'm using the HttpClient for an HttpRequest Message. The HttpClient constructor accepts a HttpClientHandler, which accepts as Credentials property an instance of CredentialCache. A CredentialCache should be able to work with digest authentication.

Code should be like:

var credCache = new CredentialCache();
credCache.Add(new Uri("http://.com/"),"Digest", new NetworkCredential(UserName,SecurelyStoredPassword,Domain));
var httpClient = new HttpClient( new HttpClientHandler { Credentials = credCache});
var answer = httpClient.GetAsync(new Uri("http://request.Uri"));


来源:https://stackoverflow.com/questions/10658202/httprequestmessage-and-digest-authentication

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!