我有一个 WCF 4 服务,它位于 Secure 子文件夹中,在客户端使用 .NET AuthenticationService 使用 Forms 身份验证进行身份验证后可以访问。
此 WCF 服务适用于通过 json 进行通信但不是 ASP.NET 应用程序的移动应用程序客户端。我已经成功地将服务配置为使用 json,并且 AuthenticationService 具有许多地方记录的标准配置,例如http://msdn.microsoft.com/en-us/library/bb398990.aspx
AuthenticationService 的文档说“应用程序必须能够发送和使用 SOAP 消息”。但是我希望客户端也能够使用 json 进行身份验证。这可能吗?需要什么配置?
我找到了这篇文章 http://weblogs.asp.net/asptest/archive/2008/12/09/working-with-the-asp-net-ajax-authentication-service.aspx所以看起来 AuthenticationService 可以处理 json 但它使用客户端应用程序服务。移动应用程序客户端不是 ASP.NET 应用程序。
最佳答案
是的,AuthenticationService 可以处理 JSON。有几种方法可以做到。这是我过去使用 使用的示例配置元素。
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
<services>
<service name="System.Web.ApplicationServices.AuthenticationService" behaviorConfiguration="MyServiceBehavior">
<endpoint address="" behaviorConfiguration="ajaxBehavior"
contract="System.Web.ApplicationServices.AuthenticationService"
binding="webHttpBinding" bindingConfiguration="webHttpBindingSecure"
bindingNamespace="http://asp.net/ApplicationServices/v200"/>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="ajaxBehavior">
<enableWebScript/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="MyServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<webHttpBinding>
<binding name="webHttpBindingSecure">
<security mode="Transport"/>
</binding>
</webHttpBinding>
</bindings>
</system.serviceModel>
关于wcf - 如何在没有 ASP.NET 的情况下从 json 客户端调用 .NET AuthenticationService,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8918322/