[英]Using DNS in URL of post Request get 401 - unauthorized but works fine if I use the actual server name in the URL
我們從 controller-A(服務器端)調用 API 到 controller-B
兩者都配置為IIS中的分離站點
**站點 A - 安全配置:**
<security>
<authentication>
<windowsAuthentication enabled="true">
<providers>
<clear />
<add value="NTLM" />
<add value="Negotiate" />
</providers>
</windowsAuthentication>
<anonymousAuthentication enabled="false" />
</authentication>
</security>
B站——安全配置:
<security>
<authentication>
<anonymousAuthentication enabled="false" />
<windowsAuthentication enabled="true"/>
<basicAuthentication enabled="true"/>
</authentication>
</security>
此處請求代碼:`
HttpClientHandler httpClientHandler = new HttpClientHandler()
{
Credentials = new CredentialCache() {
{
httpRequest.RequestUri,
"NTLM",
CredentialCache.DefaultNetworkCredentials
} }
};
var response = await new HttpClient(httpClientHandler).PostAsync(url, data);
` 當 url 是: https://serverName.domain:4444/home/apiName - 一切正常
但是當https://VipName.domain:4444/home/apiName - 得到 401
感謝您的幫助!!!
在 IIS 日志中我們可以看到用戶未通過
對於發送憑據的瀏覽器,它必須是受信任的站點。 “serverName.domain”可能是可信的,但“VipName.domain”不是。
Chrome 和 Edge 使用 Inte.net 選項中的可信站點:
Firefox有自己的設置,你可以在這里看到: https://superuser.com/a/878494/233663
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.