asp.net - 身份验证模式 ="Forms"导致 WCF 端点出现错误

标签 asp.net wcf visual-studio-2010 authentication endpoint

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

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:

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

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

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

最佳答案

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

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

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

<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

关于asp.net - 身份验证模式 ="Forms"导致 WCF 端点出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5593720/

相关文章:

asp.net - 用于 ASP.NET 的良好日期选择器

c# - 从 WCF 创建客户端查看 SOAP XML

json - WCF 服务速度慢 - 有选项吗?

wcf - 如何将 Ninject2 与 WCF 结合使用?

c++ - 类间内存分配重合

c++ - ShellExecute 崩溃

c# - 使用 Silverlight 播放用户的歌曲

javascript - ASP.NET 从 Javascript 调用函数背后的代码

c# - C# 中 instagram API 中使用的时间戳时间

c# - 添加带有颜色指示器 ASP.NET 图表的自定义图例