Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I configure WCF to accept SSL and non-SSL
    text
    copied!<p>I need some help configuring WCF to support multiple environments. One environment allows anonymous authentication over standard HTTP and the other uses Windows Authentication over SSL. </p> <p>I can configure WCF to support either of the environments, but not both within the same web.config file. </p> <p>Here's what allows anonymous over http:</p> <pre><code>&lt;behaviors&gt; &lt;serviceBehaviors&gt; &lt;behavior name="MexBehavior" &gt; &lt;serviceMetadata httpGetEnabled="true" /&gt; &lt;/behavior&gt; &lt;/serviceBehaviors&gt; &lt;endpointBehaviors&gt; &lt;behavior name="DLAspNetAjaxBehavior"&gt; &lt;enableWebScript/&gt; &lt;/behavior&gt; &lt;behavior name="Service1AspNetAjaxBehavior"&gt; &lt;webHttp/&gt; &lt;/behavior&gt; &lt;/endpointBehaviors&gt; &lt;/behaviors&gt; &lt;serviceHostingEnvironment aspNetCompatibilityEnabled="true"/&gt; &lt;services&gt; &lt;service name="DL" behaviorConfiguration="MexBehavior"&gt; &lt;endpoint address="" behaviorConfiguration="DLAspNetAjaxBehavior" binding="webHttpBinding" contract="DLService"/&gt; &lt;endpoint name="MEXEndpoint" contract="IMetadataExchange" binding="mexHttpBinding" address="mex" /&gt; &lt;/service&gt; &lt;service name="Service1" behaviorConfiguration="MexBehavior"&gt; &lt;endpoint address="" behaviorConfiguration="Service1AspNetAjaxBehavior" binding="webHttpBinding" contract="Service1"/&gt; &lt;endpoint name="MEXEndpoint" contract="IMetadataExchange" binding="mexHttpBinding" address="mex" /&gt; &lt;/service&gt; &lt;/services&gt; </code></pre> <p>And here's what works for Windows Authentication over SSL:</p> <pre><code>&lt;behaviors&gt; &lt;serviceBehaviors&gt; &lt;behavior name="MexBehavior" &gt; &lt;serviceMetadata httpGetEnabled="true" /&gt; &lt;/behavior&gt; &lt;/serviceBehaviors&gt; &lt;endpointBehaviors&gt; &lt;behavior name="DLAspNetAjaxBehavior"&gt; &lt;enableWebScript/&gt; &lt;/behavior&gt; &lt;behavior name="Service1AspNetAjaxBehavior"&gt; &lt;webHttp/&gt; &lt;/behavior&gt; &lt;/endpointBehaviors&gt; &lt;/behaviors&gt; &lt;serviceHostingEnvironment aspNetCompatibilityEnabled="true"/&gt; &lt;services&gt; &lt;service name="DL" behaviorConfiguration="MexBehavior"&gt; &lt;endpoint address="" behaviorConfiguration="DynamicLoaderAspNetAjaxBehavior" binding="webHttpBinding" bindingConfiguration="webWinBinding" contract="DLService"/&gt; &lt;endpoint name="MEXEndpoint" contract="IMetadataExchange" binding="mexHttpBinding" address="mex" /&gt; &lt;/service&gt; &lt;service name="Service1" behaviorConfiguration="MexBehavior"&gt; &lt;endpoint address="" behaviorConfiguration="ValidValuesServiceAspNetAjaxBehavior" binding="webHttpBinding" bindingConfiguration="webWinBinding" contract="Service1"/&gt; &lt;endpoint name="MEXEndpoint" contract="IMetadataExchange" binding="mexHttpBinding" address="mex" /&gt; &lt;/service&gt; &lt;/services&gt; &lt;bindings&gt; &lt;webHttpBinding&gt; &lt;binding name="webWinBinding"&gt; &lt;security mode="Transport"&gt; &lt;transport clientCredentialType="Windows" /&gt; &lt;/security&gt; &lt;/binding&gt; &lt;/webHttpBinding&gt; &lt;/bindings&gt; </code></pre> <p>When I add the endpoint from the SSL configuration to the non-SSL configuration, the anonymous service breaks.</p> <p>Here is the config file that doesn't work but attempts to put both settings together:</p> <pre><code>&lt;behaviors&gt; &lt;serviceBehaviors&gt; &lt;behavior name="MexBehavior" &gt; &lt;serviceMetadata httpGetEnabled="true" /&gt; &lt;/behavior&gt; &lt;/serviceBehaviors&gt; &lt;endpointBehaviors&gt; &lt;behavior name="DLAspNetAjaxBehavior"&gt; &lt;enableWebScript/&gt; &lt;/behavior&gt; &lt;behavior name="Service1AspNetAjaxBehavior"&gt; &lt;webHttp/&gt; &lt;/behavior&gt; &lt;/endpointBehaviors&gt; &lt;/behaviors&gt; &lt;serviceHostingEnvironment aspNetCompatibilityEnabled="true"/&gt; &lt;services&gt; &lt;service name="DynamicLoader" behaviorConfiguration="MexBehavior"&gt; &lt;endpoint name="basic" address="" behaviorConfiguration="DLAspNetAjaxBehavior" binding="webHttpBinding" bindingConfiguration="webAnonymousBinding" contract="DLService"/&gt; &lt;endpoint name="secure" address="" behaviorConfiguration="DLAspNetAjaxBehavior" binding="webHttpBinding" bindingConfiguration="webWinBinding" contract="DLService"/&gt; &lt;endpoint name="MEXEndpoint" contract="IMetadataExchange" binding="mexHttpBinding" address="mex" /&gt; &lt;/service&gt; &lt;service name="ValidValuesService" behaviorConfiguration="MexBehavior"&gt; &lt;endpoint name="basic" address="" behaviorConfiguration="Service1AspNetAjaxBehavior" binding="webHttpBinding" bindingConfiguration="webAnonymousBinding" contract="Service1"/&gt; &lt;endpoint name="secure" address="" behaviorConfiguration="Service1AspNetAjaxBehavior" binding="webHttpBinding" bindingConfiguration="webWinBinding" contract="Service1"/&gt; &lt;endpoint name="MEXEndpoint" contract="IMetadataExchange" binding="mexHttpBinding" address="mex" /&gt; &lt;/service&gt; &lt;/services&gt; &lt;bindings&gt; &lt;webHttpBinding&gt; &lt;binding name="webWinBinding"&gt; &lt;security mode="Transport"&gt; &lt;transport clientCredentialType="Windows" /&gt; &lt;/security&gt; &lt;/binding&gt; &lt;binding name="webAnonymousBinding"&gt; &lt;security mode="None"&gt; &lt;/security&gt; &lt;/binding&gt; &lt;/webHttpBinding&gt; &lt;/bindings&gt; </code></pre> <p>Is there some way I can combine the endpoints into one web.config to support the two environments?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload