2017-04-06 36 views
0

我有一個WCF服務應用程序,它使用.NET Fraweork 4.5.2和應用程序池,其中Managed pipeline mode設置爲Integrated。我使用基本身份驗證來使用此WCF服務。我已經部署了應用程序以兩個環境(devqa),在dev它完美的作品,但在qa我得到以下錯誤:WCF服務應用程序不允許基本身份驗證配置

enter image description here

下面是應用程序的IIS身份驗證配置:

enter image description here

這是我web.config

<system.serviceModel> 
    <bindings> 
     <basicHttpBinding> 
      <binding> 
       <security mode="TransportCredentialOnly"> 
        <transport clientCredentialType="Basic" /> 
       </security> 
      </binding> 
     </basicHttpBinding> 
    </bindings> 
    <services> 
     <service name="MyProject.IS01" 
       behaviorConfiguration="ServiceWithMetaData"> 
      <endpoint name="Default" 
       address="" 
       binding="basicHttpBinding" 
       contract="MyProject.IIS01" /> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
      <behavior name="ServiceWithMetaData"> 
       <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" /> 
       <serviceDebug includeExceptionDetailInFaults="false" /> 
      </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <serviceHostingEnvironment 
      aspNetCompatibilityEnabled="true" 
      multipleSiteBindingsEnabled="true" /> 
</system.serviceModel> 
<system.webServer> 
    <modules runAllManagedModulesForAllRequests="true"> 
     <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" preCondition="managedHandler" /> 
     <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" preCondition="managedHandler" /> 
     <add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" preCondition="managedHandler" /> 
    </modules> 
    <directoryBrowse enabled="true" /> 
    <validation validateIntegratedModeConfiguration="false" /> 
</system.webServer> 

消息錯誤的第一個短語對我來說非常有用。它表示身份驗證設置爲Windows,但正如您在第二個屏幕截圖中看到的,Windows身份驗證已禁用。

缺少配置中的東西嗎?我應該在託管IIS的服務器上激活某些功能嗎?

我提到我在google上發現的所有問題都與匿名身份驗證(而不是基本身份驗證)有關。

在此先感謝。

回答

0

這是因爲您缺少服務端點中的BindingConfiguration設置,因此根本沒有應用該配置。像下面那樣改變它

<bindings> 
    <basicHttpBinding> 
    <binding name="testbinding"> 
     <security mode="TransportCredentialOnly"> 
     <transport clientCredentialType="Basic" /> 
     </security> 
    </binding> 
    </basicHttpBinding> 
</bindings> 


<services> 
    <service name="MyProject.IS01" behaviorConfiguration="ServiceWithMetaData"> 
    <endpoint name="Default" address="" binding="basicHttpBinding" 
contract="MyProject.IIS01" bindingConfiguration="testbinding" /> 
    </service> 
</services> 
+0

初始配置有一個綁定名稱(我也有'bindingConfiguration'屬性指向它),我有同樣的錯誤。 – roroinpho21

+0

@ roroinpho21,首先嚐試發佈的答案,如果不起作用,然後返回確切的錯誤消息 – Rahul

+0

我修復了在應用程序池上重新啓動的問題 – roroinpho21