【问题标题】:.Net 4.0+WCF+WIndows Authentication + IIS.Net 4.0+WCF+Windows 身份验证+IIS
【发布时间】:2011-03-01 04:55:13
【问题描述】:

我正在尝试在支持 Windows 身份验证的 IIS 中托管我的 WCF 服务。我可以使用 Framework 3.5 来做到这一点,但是当我将 Framework 更改为 4.0 时,它会出现以下错误。

此服务的安全设置需要“匿名”身份验证,但托管此服务的 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>

【问题讨论】:

    标签: wcf .net-4.0


    【解决方案1】:

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

    在 UI 中,您需要执行以下操作:

    • 打开 IIS 管理器,然后左键单击您的网站/应用程序
    • 在“功能”窗格中,双击“身份验证”
    • 在身份验证页面上,右键单击匿名身份验证项并选择启用。

    【讨论】:

    • 我不想匿名访问。它应该仅基于 Windows 身份验证。匿名身份验证带走了 windows 身份验证的所有好处。
    • 您的服务需要匿名身份验证,因为 。将 httpGetEnabled 设置为 false 应该会删除该要求。
    • 即使我把它设为假,我也会得到同样的错误。相同的配置适用于 3.5。
    • 嗯终于解决了这个问题。感谢您的回复。但它与 IIS 无关。我应该在服务名称和合同中使用完全限定名称。请在下面找到代码。
    猜你喜欢
    • 2011-07-22
    • 1970-01-01
    • 1970-01-01
    • 2011-08-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-13
    • 1970-01-01
    相关资源
    最近更新 更多