Configure SSL binding for RESTful WCF. How?

后端 未结 3 1156
别那么骄傲
别那么骄傲 2021-01-13 13:45

My current config looks like so:


    
    

        
相关标签:
3条回答
  • 2021-01-13 14:28

    Do what the error says... fix your binding

     <services>
          <service name="service" behaviorConfiguration="serviceBehavior">
            <endpoint address="" binding="webHttpBinding"
                  bindingConfiguration="https"
    contract="IContract" behaviorConfiguration="endpointBehavior">
            </endpoint>
          </service>
        </services> 
    
    <bindings>
     <webHttpBinding>
      <binding name="https" maxReceivedMessageSize="65536">
        <security mode="Transport" />
        <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
                            maxArrayLength="2147483647"
                            maxBytesPerRead="2147483647"
                            maxNameTableCharCount="2147483647" />
    
      </binding>
     </webHttpBinding>
    </bindings>
    
    0 讨论(0)
  • 2021-01-13 14:32

    Try this

    <system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
    <standardEndpoints>
      <webHttpEndpoint>
        <!--Set limit to 5 megabytes-->
        <standardEndpoint helpEnabled="true" automaticFormatSelectionEnabled="true" maxReceivedMessageSize="5242880">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
                        maxArrayLength="2147483647"
                        maxBytesPerRead="2147483647"
                        maxNameTableCharCount="2147483647" />
    
        </standardEndpoint>
        <security mode="Transport" />
      </webHttpEndpoint>
    </standardEndpoints>
    </system.serviceModel>
    
    0 讨论(0)
  • 2021-01-13 14:35

    The accepted answer did not work for me because I needed to keep my standard endpoints element. I was able to remove my http-binding and only leave the https-binding in IIS by adding a <webHttpBinding> section to my Web.config

    Make sure to not set the name property on the <binding>, otherwise this will not work

    Relevant part of my Web.config:

     <system.serviceModel>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
        <bindings>
          <webHttpBinding>
            <binding>
              <!-- Comment out the following line if HTTP is used. If HTTPS is used, leave it enabled -->
              <security mode="Transport"/>
            </binding>
          </webHttpBinding>
        </bindings>
        <standardEndpoints>
          <webHttpEndpoint>
            <standardEndpoint name="" helpEnabled="false" automaticFormatSelectionEnabled="true"/>
          </webHttpEndpoint>
        </standardEndpoints>
      </system.serviceModel>
    
    0 讨论(0)
提交回复
热议问题