Sto cercando di utilizzare https & http per il sito web. Il sito Web ha file .svc che fungono da servizio REST e chiamati da JavaScript.WebHttpBinding con Http e Https
mia configurazione:
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="AjaxBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="MyServiceBehaviour">
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceMetadata httpGetEnabled="True" httpsGetEnabled="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
<services>
<service behaviorConfiguration="MyServiceBehaviour" name="MyService.Lookups">
<endpoint address="" behaviorConfiguration="AjaxBehavior"
binding="webHttpBinding" bindingConfiguration="httpWebBinding" contract="MyService.Lookups" >
</endpoint>
<endpoint address="" behaviorConfiguration="AjaxBehavior"
binding="webHttpBinding" bindingConfiguration="httpsWebBinding" contract="MyService.Lookups" >
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<bindings>
<webHttpBinding>
<binding name="httpsWebBinding">
<security mode="Transport">
<transport clientCredentialType="None" proxyCredentialType="None" />
</security>
</binding>
<binding name="httpWebBinding">
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None" />
</security>
</binding>
</webHttpBinding>
</bindings>
</system.serviceModel>
Navigazione https://myserver/services/Lookups.svc/Hello dà
Impossibile trovare un indirizzo di base che corrisponde schema http per l'endpoint con il legame webHttpBinding. schemi di indirizzo base registrata sono [https]
Navigazione http://myserver/services/Lookups.svc/Hello dà
Impossibile trovare un indirizzo di base che corrisponde schema HTTPS per l'endpoint con il legame webHttpBinding. Gli schemi di indirizzi di base registrati sono [http]
Se rimuovo un qualsiasi endpoint funziona. Esempio di rimozione dell'endpoint configurato con bindingConfiguration="httpWebBinding"
per HTTPS,
Come posso farlo funzionare con HTTP e HTTPS? A partire da ora, posso usare http o https rimuovendo un endpoint.
Riferito How can I combine the WCF services config for both http and https in one web.config? e How do you setup HTTP and HTTPS WCF 4 RESTful services?
Nota: In IIS, si tratta di due siti web un ascolto su http e un altro sul https. Entrambi condividono lo stesso codice nella cartella fisica
UPDATE: A partire da ora, ho rimosso gli endpoint e funziona. Ma la mia preoccupazione è la rimozione di endpoing configurato con comportamentConfigurazione non sembra un'ottima soluzione per me.
Questo funziona sia per http & https
<services>
<service behaviorConfiguration="MyServiceBehaviour" name="MyService.Lookups">
</service>
</services>
con 'httpsGetEnabled =" true "' ci deve essere un url 'https', ma non ne è stato definito alcuno. –