简体   繁体   中英

HttpRequestMessage and Digest Authentication

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.

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"));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM