在共享 Web 主机上托管 WCF 数据服务时出现 IIS 错误

发布于 2024-09-28 06:26:10 字数 1193 浏览 2 评论 0原文

我的客户有一个托管在共享网络服务器上的网站。我无法访问 IIS。我正在尝试将 WCF 数据服务部署到他的站点上。我收到此错误:

IIS 指定了身份验证方案“IntegratedWindowsAuthentication,Anonymous”,但绑定仅支持指定一种身份验证方案。有效的身份验证方案包括摘要式、协商式、NTLM、基本式或匿名式。更改 IIS 设置,以便仅使用单一身份验证方案。

我已经搜索了很多网站和其他网站,但似乎找不到与我的情况完全一样的人。我无法更改 IIS 设置,因为这是第三方服务器并且是共享 Web 服务器。所以我唯一的选择是更改代码或服务配置中的内容。我的服务配置如下所示:

<system.serviceModel xdt:Transform="Insert">
  <serviceHostingEnvironment>
    <baseAddressPrefixFilters>
      <add prefix="http://www.somewebsite.com"/>
    </baseAddressPrefixFilters>
  </serviceHostingEnvironment>
  <bindings>
    <webHttpBinding>
      <binding name="{Binding Name}" >
        <security mode="None" />
      </binding>
    </webHttpBinding>
  </bindings>
  <services>
    <service name="{Namespace to Service}">
      <endpoint address="" binding="webHttpBinding" bindingConfiguration="{Binding Name}" contract="System.Data.Services.IRequestHandler">
      </endpoint>
    </service>
  </services>
</system.serviceModel>

如您所见,我尝试将安全模式设置为“无”,但这似乎没有帮助。我应该更改什么来解决此错误?

My client has a website hosted on a shared web server. I don't have access to IIS. I am trying to deploy a WCF Data Service onto his site. I am getting this error:

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 searched SO and other sites quite a bit but can't seem to find someone with my exact situation. I cannot change the IIS settings because this is a third party's server and it is a shared web server. So my only option is to change things in code or in the service config. My service config looks like this:

<system.serviceModel xdt:Transform="Insert">
  <serviceHostingEnvironment>
    <baseAddressPrefixFilters>
      <add prefix="http://www.somewebsite.com"/>
    </baseAddressPrefixFilters>
  </serviceHostingEnvironment>
  <bindings>
    <webHttpBinding>
      <binding name="{Binding Name}" >
        <security mode="None" />
      </binding>
    </webHttpBinding>
  </bindings>
  <services>
    <service name="{Namespace to Service}">
      <endpoint address="" binding="webHttpBinding" bindingConfiguration="{Binding Name}" contract="System.Data.Services.IRequestHandler">
      </endpoint>
    </service>
  </services>
</system.serviceModel>

As you can see I tried to set the security mode to "None" but that didn't seem to help. What should I change to resolve this error?

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

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

发布评论

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

评论(1

夜司空 2024-10-05 06:26:10

我对此不太确定,但通过阅读 这篇文章我认为您不能直接从配置将身份验证设置为无。

Windows 身份验证设置是通过 IIS 进行的。

在调用任何数据之前,您是否尝试过在代码中执行此操作:

MyDataContext ctx = new MyDataContext(uri); 
ctx.Credentials = System.Net.CredentialCache.DefaultCredentials;  
ctx.Credentials = new NetworkCredential( 
    "username", 
    "password", 
    "domain");

当然,您必须拥有用户名、密码和域。

希望有帮助=)

Im not too sure about this but from reading this article I think you cannot set the authentication to none straight from the config.

The windows auth settings are made via IIS.

Have you tried doing this in your code, before you call any data:

MyDataContext ctx = new MyDataContext(uri); 
ctx.Credentials = System.Net.CredentialCache.DefaultCredentials;  
ctx.Credentials = new NetworkCredential( 
    "username", 
    "password", 
    "domain");

Of course you have to have the username, password and domain.

Hope that helped =)

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