2013-03-04 69 views
2

我有一個使用表單身份驗證的MVC應用程序。此應用程序還承載WCF Web服務(模型)。 Webservice將c#對象添加到應用程序中,並且從應用程序(瀏覽器)外部調用時可以使用與JSON相同的數據。 除了Web服務沒有對​​任何請求進行身份驗證這一事實外,一切都工作正常。以下是我在web.config中的內容:mvc wcf安全

<system.serviceModel> 
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> 
<behaviors> 
    <endpointBehaviors> 
    <behavior name="ServiceBehavior"> 
     <webHttp /> 
    </behavior> 
    </endpointBehaviors> 
</behaviors> 
<bindings> 
    <webHttpBinding> 
    <binding name="webHttpBindingWithJson" crossDomainScriptAccessEnabled="true" /> 
    </webHttpBinding> 
</bindings> 
<services> 
    <service name="Services.MyService"> 
    <endpoint address="http://localhost:1234/MyService.svc/" binding="webHttpBinding" 
       bindingConfiguration="webHttpBindingWithJson" 
       contract="Services.IService" 
       behaviorConfiguration="ServiceBehavior"/> 
    </service> 
</services> 

我想驗證web服務請求:在應用程序中

  • 請求應自動驗證
  • 當web服務從應用程序外部調用,用戶被要求進行認證。

任何幫助,將不勝感激。

/d

回答

0

聽起來像是你需要的服務的WSDL內部端點綁定到網站,併爲JSON單獨綁定外部(使用ASP.NET身份的網站下運行驗證)請求使用類似OAuth進行身份驗證。

無論哪種方式,你正在尋找兩種不同的身份驗證機制。