【问题标题】:WCF 4 Rest Service on IIS Developer Express, Authentication IssueIIS Developer Express 上的 WCF 4 Rest 服务,身份验证问题
【发布时间】:2011-03-28 21:29:36
【问题描述】:

当我在 IIS Developer Express 中托管 “WCF 4 Rest Service Template” 项目(来自模板)时,我得到以下信息:

IIS 指定了身份验证方案“IntegratedWindowsAuthentication, Anonymous”,但绑定只支持指定一个身份验证方案。有效的身份验证方案是 Digest、Negotiate、NTLM、Basic 或 Anonymous。更改 IIS 设置,以便只使用一个身份验证方案。

除了将 automaticFormatSelectionEnabled 设置为 false 以返回 JSON 之外,我没有显式更改任何配置:

<system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
    <standardEndpoints>
      <webHttpEndpoint>
            <!--Configure the WCF REST service base address via the global.asax.cs file and the default endpoint 
            via the attributes on the <standardEndpoint> element below-->
        <standardEndpoint name="" 
                          helpEnabled="true" 
                          automaticFormatSelectionEnabled="false"
                          />
      </webHttpEndpoint>
    </standardEndpoints>
  </system.serviceModel>

如果端点配置未明确设置是问题,那么我将如何为此类服务执行此操作,以便明确设置服务的身份验证方案以避免 iis developer express 出现此问题?

注意:我在 Web 服务项目 /bin 中有以下程序集 Microsoft.Web.dllMicrosoft.Web.Administration.dll > 应用程序的文件夹,如 iss 团队博客上用于跳入 WCF 服务的解决方法中所述: http://blogs.iis.net/vaidyg/archive/2010/07/21/wcf-workaround-for-webmatrix-beta.aspx

【问题讨论】:

    标签: wcf iis-7 .net-4.0 wcf-rest wcf-configuration


    【解决方案1】:

    您将需要禁用不需要的身份验证方案,我猜是 Windows 身份验证。所以:

    1. 启动记事本
    2. 在记事本文件中打开:%userprofile%\Documents\IISExpress8\config\applicationhost.config
    3. 搜索
    4. 将启用的属性从 真到假
    5. 保存

    这将禁用所有站点的 Windows 身份验证,您也可以在文件底部的最后 行之前为特定站点(在本例中为 YourSite)添加位置路径添加:

    <location path="YourSite" overrideMode="Allow">
        <system.webServer>
            <security>
                <windowsAuthentication enabled="false" />
            </security>
        </system.webServer>
    </location>
    

    这只会禁用特定网站的功能。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多