這個問題很久沒有解決,但我認爲如果我發佈我的答案,它會幫助別人。
當然,您可以返回AuthenticationService的json。 解決方案非常簡單,就像Garret的答案一樣,您只需要配置另一個端點,但您需要爲端點行爲添加2個附加屬性:defaultOutgoingResponseFormat =「Json」和defaultBodyStyle =「Wrapped」以覆蓋默認的soap響應。
<system.serviceModel>
<services>
<service behaviorConfiguration="AuthenticationServiceBehaviors" name="System.Web.ApplicationServices.AuthenticationService">
<endpoint address="" behaviorConfiguration="ajaxBehavior"
contract="System.Web.ApplicationServices.AuthenticationService"
binding="webHttpBinding" bindingConfiguration="RestBinding"
bindingNamespace="http://asp.net/ApplicationServices/v200"/>
</service>
</services>
<bindings>
<webHttpBinding>
<binding name="RestBinding" />
</webHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="ajaxBehavior">
<webHttp helpEnabled="true" defaultOutgoingResponseFormat="Json" defaultBodyStyle="Wrapped" />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="AuthenticationServiceBehaviors">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true" />
我希望這個幫人誰希望暴露asp.net成員資格JSON格式的移動應用程序使用。
這是有幫助的。您是否使用了自動生成的代理(例如authsvc.svc/js)或自定義JavaScript代碼?請考慮發佈您的客戶端代碼。 – BillVo 2015-07-07 14:32:21
嗨@BillVo我使用這個自動生成的代理服務器:authsvc/login ...當你已經暴露了這個enpoint作爲JSON,你可以從任何地方使用Javascript到移動應用程序的Web應用程序。請在客戶端需要示例代碼時參考google,因爲每個客戶端堆棧都有不同的語法。問候。 – tungnt185 2015-07-08 03:40:55