0

我在 IIS 中配置了网站。是主default web site网站MVC applicationWCF applicationdefault web site. 像下面的东西

在此处输入图像描述

default web site使用 cookie 身份验证的 OpenID 连接身份验证。因此,当用户尝试default web site从其子应用程序访问任何资源时,他会被重定向到登录页面。这按预期工作正常。

现在我有一个要求,应用程序需要在单击按钮MVC时从服务调用操作。WCF所以我在 MVC 应用程序中添加了一个服务引用并配置了如下绑定

WCF 服务配置

    <system.serviceModel>
        <extensions>
          <behaviorExtensions>
            <add name="silverlightFaults" type="Framework.Wcf.SilverlightFaultBehavior, Framework, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b297de4b0f792ff8" />
          </behaviorExtensions>
        </extensions>
        <services>
          <service name="DocumentManagementService.DocumentManagementService" behaviorConfiguration="DocumentManagementServiceBehavior">
            <endpoint name="BasicHttpEndPoint" binding="basicHttpBinding" contract="DocumentManagementService.Contracts.IDocumentManagement" bindingConfiguration="BasicHttpEndPoint" behaviorConfiguration="SilverlightFaultBehavior" />        
          </service>
        </services>
        <bindings>
          <basicHttpBinding>
            <binding name="BasicHttpEndPoint" closeTimeout="00:2:00" openTimeout="00:2:00" receiveTimeout="0:5:00" sendTimeout="00:5:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="104857600" maxBufferPoolSize="524288" maxReceivedMessageSize="104857600" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
              <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="104857600" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
              <security mode="Transport">
                <transport clientCredentialType="None" proxyCredentialType="None" realm="" />
                <message clientCredentialType="UserName" algorithmSuite="Default" />
              </security>
            </binding>
          </basicHttpBinding>
        </bindings>
        <behaviors>
          <serviceBehaviors>
            <behavior name="DocumentManagementServiceBehavior">          
              <serviceMetadata httpGetEnabled="false" httpsGetEnabled="true"/>          
              <serviceDebug includeExceptionDetailInFaults="false" />
            </behavior>
          </serviceBehaviors>
          <endpointBehaviors>
            <behavior name="SilverlightFaultBehavior">
              <silverlightFaults />
            </behavior>
          </endpointBehaviors>
        </behaviors>
        <serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true" />
     </system.serviceModel>

MVC 配置(这是客户端)

  <system.serviceModel>
    <bindings>
       <basicHttpBinding>        
          <binding name="BasicHttpEndPoint" closeTimeout="00:2:00" openTimeout="00:2:00" receiveTimeout="0:5:00" sendTimeout="00:5:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="104857600" maxBufferPoolSize="524288" maxReceivedMessageSize="104857600" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
              <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="104857600" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
              <security mode="Transport">
                <transport clientCredentialType="None" proxyCredentialType="None" realm="" />
                <message clientCredentialType="UserName" algorithmSuite="Default" />
              </security>
        </binding> 
      </basicHttpBinding>     
    </bindings>
    <client>
      <endpoint address="https://XXXXX/DocumentManagementService/DocumentManagementService.svc"
        binding="basicHttpBinding" bindingConfiguration="BasicHttpEndPoint"
        contract="DMProxy.IDocumentManagement" name="BasicHttpEndPoint" />
    </client>
  </system.serviceModel>

但是,当我调用 WCF 操作时,我得到了错误

HTTP 请求未经客户端身份验证方案“匿名”授权。从服务器收到的身份验证标头是“”。

请注意,当用户单击按钮时,那时他已经通过了身份验证。我不确定该身份验证将如何传递给 WCF 应用程序。

更新 1

默认网站的 IIS 身份验证

在此处输入图像描述

WCF 的 IIS 身份验证

在此处输入图像描述

更新 2 我认为* 在进行 WCF 调用之前,我需要在 Cookies 和 HttpHeader 中添加身份验证 cookie。?? 知道我会怎么做

4

0 回答 0