认证模式=“表单”导致 WCF 端点错误

发布于 2024-10-31 07:38:29 字数 522 浏览 5 评论 0原文

我的 .NET 4.0 Web 应用程序项目中有一个 WCF 端点。使用VS2010 WCF测试客户端,我可以正确连接到该服务。但是,当我使用该服务时,我收到一条通用错误消息:

内容类型text/html;响应消息的 charset=UTF-8 与绑定的内容类型(text/xml;charset=utf-8)不匹配。如果使用自定义编码器,请确保正确实现 IsContentTypeSupported 方法。响应的前 1024 个字节是:

我发现当我从 web.config 文件中删除身份验证时,服务可以正常工作:

<authentication mode="Forms">
  <forms cookieless="AutoDetect" loginUrl="~/Security/LoginClient.aspx" name="FORMAUTH" />
</authentication>

有什么想法可以从身份验证中删除此服务吗?

I have a WCF end point inside my .NET 4.0 Web Application project. Using the VS2010 WCF Test Client, I can connect to the service correctly. However when I go to use the service I get a generic error message:

The content type text/html; charset=UTF-8 of the response message does not match the content type of the binding (text/xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 1024 bytes of the response were:

I have discovered that when I remove the authentication from the web.config file the service works correctly:

<authentication mode="Forms">
  <forms cookieless="AutoDetect" loginUrl="~/Security/LoginClient.aspx" name="FORMAUTH" />
</authentication>

Any ideas how I can remove just this service from the authentication?

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

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

发布评论

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

评论(1

恋竹姑娘 2024-11-07 07:38:29

您可以使用 web.config 中的位置节点从表单身份验证中排除特定文件:

<location path="MyService.svc">
   <system.web>
      <authorization>
          <allow users="*" />
      </authorization>
   </system.web>
</location>

一种更简单的方法是将不需要身份验证的服务相关文件分组到公共文件夹中并允许访问整个文件夹:

<location path="MyServiceFolder/">
   <system.web>
      <authorization>
         <allow users="*" />
      </authorization>
   </system.web>
</location>

有关MSDN 上的位置元素:

http://msdn.microsoft。 com/en-us/library/b6x6shw7%28vs.71%29.aspx

You can exclude specific files from forms authentication with a location node in web.config:

<location path="MyService.svc">
   <system.web>
      <authorization>
          <allow users="*" />
      </authorization>
   </system.web>
</location>

An easier way would just be to group the service related files don't require authentication into a public folder and allow access to the entire folder:

<location path="MyServiceFolder/">
   <system.web>
      <authorization>
         <allow users="*" />
      </authorization>
   </system.web>
</location>

More information on the location element on MSDN:

http://msdn.microsoft.com/en-us/library/b6x6shw7%28vs.71%29.aspx

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