none
How to configure IIS web.config in order to add 'http' connections when 'https' are already working with the following web.config? RRS feed

  • Question

  • Good morning,

       Can someone give me some help about the following issue?

       Context

       I got a wcf iis web service up and running. 
       The web config is made to accept only https connections and works fine.

       My question

       I need to add the possibility to connect with http too, how can I modify the existing web.config to achieve this?

       My Web.config

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <system.diagnostics>
        <trace autoflush="true">
          <listeners>
            <add name="textWriterTraceListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="C:\Temp\log4net.txt" />
          </listeners>
        </trace>
      </system.diagnostics>

      <system.web>
        <compilation debug="true" targetFramework="4.5.2">
          <assemblies>
            <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
          </assemblies>
        </compilation>
        <customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm" />
      </system.web>
      <system.serviceModel>
        <bindings>
          <webHttpBinding>
            <binding name="webHttpTransportSecurity">
              <security mode="Transport" />
            </binding>
          </webHttpBinding>
        </bindings>
        <services>
          <service name="WSComptaPlus.ServiceComptaPlus" behaviorConfiguration="ServiceBehaviour">
            <endpoint address="" 
                      binding="webHttpBinding" 
                      bindingConfiguration="webHttpTransportSecurity" 
                      behaviorConfiguration="jsonEndpointBehavior" 
                      name="json" 
                      contract="WSComptaPlus.IServiceComptaPlus" />

            <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />

          </service>
        </services>
        <behaviors>
          <serviceBehaviors>
            <behavior name="ServiceBehaviour">
              <serviceMetadata httpsGetEnabled="true" />
              <serviceDebug includeExceptionDetailInFaults="false" />
            </behavior>
          </serviceBehaviors>
          <endpointBehaviors>
            <behavior name="jsonEndpointBehavior">
              <webHttp />
            </behavior>
            <behavior name="wsHttpBinding" />
          </endpointBehaviors>
        </behaviors>
        <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
      </system.serviceModel>
      <system.webServer>
        <directoryBrowse enabled="true" />
        <modules runAllManagedModulesForAllRequests="true" />
      </system.webServer>
      <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <dependentAssembly>
            <!-- install-package newtonsoft.json -->
            <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-11.0.0.0" newVersion="11.0.0.0" />
          </dependentAssembly>
        </assemblyBinding>
      </runtime>
    </configuration>


       
    Saturday, December 29, 2018 9:33 AM

All replies

  • Hi csi-bxl,
    The only thing we need do is add the additional endpoint to the service contract.
    You could refer to the following configuration.
     
     <system.serviceModel>
        <services>
          <service behaviorConfiguration="mybehavior" name="WcfService1.Service1">
    <!--http, https are all configurated-->
            <endpoint address="" binding="webHttpBinding" contract="WcfService1.IService1" behaviorConfiguration="webbev" bindingConfiguration="https"></endpoint>
            <endpoint address="" binding="webHttpBinding" contract="WcfService1.IService1" behaviorConfiguration="webbev" bindingConfiguration="http"></endpoint>
            <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"></endpoint>
          </service>
        </services>
        <bindings>
          <webHttpBinding>
            <binding name="https" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" sendTimeout="00:10:00" receiveTimeout="00:10:00">
              <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" />
              <security mode="Transport">
                <transport clientCredentialType="None"></transport>
              </security>
            </binding>
            <binding name="http">
              <security mode="None"></security>
            </binding>
          </webHttpBinding>
    </bindings>
    

    And then we should set up http/https protocol binding in IIS site binding.
    https://i.stack.imgur.com/jVMGJ.pngFeel free to let me know if there is anything I can help with.
    Best Regards
    Abraham
    Monday, December 31, 2018 1:57 AM
    Moderator