【问题标题】:WCF Service Hosted in ASP.NET website - Windows Authentication not working托管在 ASP.NET 网站中的 WCF 服务 - Windows 身份验证不起作用
【发布时间】:2015-06-19 08:18:51
【问题描述】:

我在一个 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 调用

$.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
    });

【问题讨论】:

    标签: asp.net windows wcf authentication iis


    【解决方案1】:

    您需要在绑定中使用“TransportCredentialOnly”属性。这篇文章解释得很好:

    https://msdn.microsoft.com/en-us/library/ff648505.aspx

    如何:在 Windows 窗体的 WCF 中将 basicHttpBinding 与 Windows 身份验证和 TransportCredentialOnly 一起使用

    这篇操作指南文章将引导您完成使用 Windows 的过程 使用 basicHttpBinding 绑定进行身份验证 TransportCredentialsOnly 安全模式。这篇文章告诉你如何 配置 WCF,配置 Internet 信息服务 (IIS) Windows 身份验证,并使用示例 WCF 客户端测试服务。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-08-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-10-04
      • 1970-01-01
      • 2019-05-19
      相关资源
      最近更新 更多