2011-03-01 165 views
0

我想在IIS中托管我的WCF服务,它支持Windows身份验证。我能够使用Framework 3.5来完成它,但是当我将Framework更改为4.0时,它会给出下面的错误。.net 4.0 + WCF + WIndows身份验证+ IIS

此服务的安全设置需要“匿名”身份验证,但它没有为承载此服务的IIS应用程序启用。

我能够在开发服务器上托管服务。但是我们必须使用IIS来完成它。

<?xml version="1.0"?> 
<configuration> 
    <system.web> 
     <compilation debug="true" targetFramework="4.0"> 
     </compilation> 
     </system.web> 
    <system.serviceModel> 
     <bindings> 
      <basicHttpBinding> 
       <binding name="BasicHttpEndpointBinding"> 
        <security mode="TransportCredentialOnly"> 
         <transport clientCredentialType="Windows"/> 
        </security> 
       </binding> 
      </basicHttpBinding> 
     </bindings> 
     <services> 
      <service name="Service1"> 
       <endpoint address="" binding="basicHttpBinding" bindingConfiguration="BasicHttpEndpointBinding" name="BasicHttpEndpoint" contract="IService1"> 
        <identity> 
         <dns value="localhost"/> 
        </identity> 
       </endpoint>   
      </service> 
     </services> 
     <behaviors> 
      <serviceBehaviors> 
       <behavior> 
        <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment --> 
        <serviceMetadata httpGetEnabled="true"/> 
        <!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information --> 
        <serviceDebug includeExceptionDetailInFaults="false"/> 
       </behavior> 
      </serviceBehaviors> 
     </behaviors> 
     <serviceHostingEnvironment multipleSiteBindingsEnabled="true"/> 
    </system.serviceModel> 
    <system.webServer> 
     <modules runAllManagedModulesForAllRequests="true"> 
     </modules> 
    </system.webServer> 
</configuration> 

回答

0

This article有关于如何为IIS7启用匿名访问的信息。

从UI,你需要做到以下几点:

  • 打开IIS管理器,然后左键点击你的网站/应用
  • 在功能窗格中,双击验证
  • 在身份验证页面,右键单击匿名身份验证项目并选择启用。
+0

我不想做匿名访问。它应该仅基于Windows身份验证。 Anonymouss身份验证取消了Windows身份验证的所有优点。 – 2011-03-01 06:10:46

+0

由于您的服务需要匿名身份验证。将httpGetEnabled设置为false应该删除该要求。 – 2011-03-01 06:30:51

+0

即使我将它保留为假,我也会得到同样的错误。相同的配置适用于3.5。 – 2011-03-01 06:37:36