簡體   English   中英

ASP.NET網站中托管的WCF服務-Windows身份驗證不起作用

[英]WCF Service Hosted in ASP.NET website - Windows Authentication not working

我在asp.net網站上托管WCF服務。 在IIS上,它具有集成的Windows身份驗證設置。 我正在使用jquery從asp.net網站頁面之一調用wcf服務方法。 但是,不幸的是,該呼叫要求我已經為網站提供的Windows用戶名/密碼。 我的理解是,身份驗證令牌也將自動傳遞給wcf調用。

如果我的配置/ ajax調用有問題,請告訴我。

以下是我的配置:

 <system.serviceModel>
<behaviors>
  <endpointBehaviors>
    <behavior name="EllipseBehavior">
      <enableWebScript />
    </behavior>
  </endpointBehaviors>
  <serviceBehaviors>
    <behavior name="EllipseBehavior" >
      <!-- Add the following element to your service behavior configuration. -->
      <serviceMetadata httpGetEnabled="true" />
    </behavior>
  </serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
<services>
  <service name="EllipseService" behaviorConfiguration="EllipseBehavior">
    <endpoint address="" behaviorConfiguration="XX.Services.Behaviour.EllipseBehavior"
      binding="webHttpBinding" contract="XX.Services.Contract.IEllipseService" />
  </service>
</services>
<bindings>
  <basicHttpBinding>

  </basicHttpBinding>
</bindings>
<client>

</client>

阿賈克斯電話

$.ajax({
        type: "GET",
        url: "/Services/Ellipse.svc/GetWorkOrdersByLine",
        data: { lineCode: workOrder.getLineCode() },
        contentType: "application/json; charset=utf-8",
        statusCode: {
            404: function() {
                alert("Incorrect URI for Service Orders");
                $.unblockUI();
            }
        },
        dataType: "json",
        success: this.onSuccess,
        error: this.onError
    });

您將需要在綁定中使用“ TransportCredentialOnly”屬性。 本文對此進行了很好的解釋:

https://msdn.microsoft.com/zh-CN/library/ff648505.aspx

如何:通過Windows窗體在WCF中將basicHttpBinding與Windows身份驗證和TransportCredentialOnly一起使用

本文介紹如何使用TransportCredentialsOnly安全模式在basicHttpBinding綁定上使用Windows身份驗證。 本文向您展示如何配置WCF,配置Windows身份驗證的Internet信息服務(IIS)以及使用示例WCF客戶端測試該服務。

暫無
暫無

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

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