如何将Win-Auth标头添加到HttpClient';s请求c#

本文关键字:请求 HttpClient Win-Auth 添加 | 更新日期: 2023-09-27 18:29:01

我需要为HttpClient模拟Win Auth http标头。它可能类似于以下内容,请参阅Authorization标题:

POST http://url HTTP/1.1
Host: http://127.0.0.1/
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:43.0) Gecko/20100101 Firefox/43.0
Accept: /
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Referer: http://127.0.0.1/
Content-Length: 18
Origin: http://127.0.0.1/
Connection: keep-alive
Authorization: NTLM TlRMTVNTUAADAAAAGAAYAIQAAABuAW4BnAAAAAAAAABYAAAAFgAWAFgAAAA
WABYAbgAAAAAAAAAKAgAABYKIogoAACgAAAAPUOVvBWOMBKcZqtqFzf+fmWQAZwByAHUAZAB6AGkAbgBzA...

请给我一些例子如何编码域名&http头的密码,我只找到了BASIC身份验证的示例。但也有windows authentication&NTLM

如何将Win-Auth标头添加到HttpClient';s请求c#

将域凭据放入HttpClientHandler中。凭据属性和AuthorizationManager将为您执行Auth舞蹈,并根据需要填写Authorization标头。