认证模式=“表单”导致 WCF 端点错误
我的 .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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 web.config 中的位置节点从表单身份验证中排除特定文件:
一种更简单的方法是将不需要身份验证的服务相关文件分组到公共文件夹中并允许访问整个文件夹:
有关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:
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:
More information on the location element on MSDN:
http://msdn.microsoft.com/en-us/library/b6x6shw7%28vs.71%29.aspx