IIS Developer Express 上的 WCF 4 Rest 服务,身份验证问题

发布于 2024-09-14 05:13:40 字数 1453 浏览 10 评论 0原文

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

IIS指定了身份验证方案“IntegratedWindowsAuthentication,Anonymous”,但绑定仅支持恰好一种认证方案的规范。有效的身份验证方案包括摘要式、协商式、NTLM、基本式或匿名式。更改 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 出现此问题?

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

When I host the "WCF 4 Rest Service Template" project (from template) in IIS Developer Express I get the following:

IIS specified authentication schemes 'IntegratedWindowsAuthentication, Anonymous', but the binding only supports specification of exactly one authentication scheme. Valid authentication schemes are Digest, Negotiate, NTLM, Basic, or Anonymous. Change the IIS settings so that only a single authentication scheme is used.

I have not changed any configuration explicitly other than setting automaticFormatSelectionEnabled to false in order to return 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>

If the endpoint configuration not being set explicitly is the issue then how would I do so for this kind of service, in order to set the authentication scheme for the service explicitly to avoid this issue with iis developer express?

Note: I have the following assemblies Microsoft.Web.dll & Microsoft.Web.Administration.dll in the web service projects /bin folder of the application as described in workaround for hopsting WCF services here on the iss team blog:
http://blogs.iis.net/vaidyg/archive/2010/07/21/wcf-workaround-for-webmatrix-beta.aspx

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

谜兔 2024-09-21 05:13:41

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

  1. 启动记事本
  2. 在记事本文件中打开: %userprofile%\Documents\IISExpress8\config\applicationhost.config
  3. 搜索
  4. 更改启用属性
    true 到 false
  5. 保存

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

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

这只会为特定站点禁用该行。

You will need to disable the authentication scheme that is not needed, my guess Windows authnetication. So:

  1. Launch Notepad
  2. Open in Notepad file: %userprofile%\Documents\IISExpress8\config\applicationhost.config
  3. Search for <windowsAuthentication
  4. Change the enabled attribute from
    true to false
  5. Save

That will disable Windows Authentication for all sites, you could alternatively add a location path at the bottom of the file right before the last </configuration> line for the specific site (YourSite in this case) add:

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

This will only disable that for the specific site.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文