簡體   English   中英

在 URL 中使用 DNS 后 Request get 401 - 未經授權但如果我在 URL 中使用實際服務器名稱則工作正常

[英]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 選項中的可信站點:

  1. Windows 密鑰 + R 並運行“.netcpl.cpl”
  2. 單擊“安全”選項卡
  3. 單擊“受信任的站點”,然后單擊“站點”按鈕
  4. 驗證“VipName.domain”是否在列表中,如果不在則添加它。 您可以使用通配符,例如“https://*.domain”

Firefox有自己的設置,你可以在這里看到: https://superuser.com/a/878494/233663

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM