WebHttpBinding with Http and Https

前端 未结 4 2063
予麋鹿
予麋鹿 2021-02-19 21:29

I am trying to use https & http for the website. The website has .svc files which act as REST service and called from JavaScript.

My Config:



        
相关标签:
4条回答
  • 2021-02-19 21:49

    As @Lesmian pointed out in his answer, the issue is in your IIS configuration. More specifically in:

    Note: In IIS, it is two web sites one listen on http and another on https. Both sharing same code in physical folder

    The reason is that IIS can not handle endpoints on a schema which it does not support.

    You have two sites, and one of them has HTTP binding but does not has HTTPS, and the other has HTTPS but not HTTP.

    So when you browse to http:// URL, IIS directs you to the (surprise!) http-enabled site, reads web.config, sees that it registers https endpoint (which is not supported by the site) and throws the exception telling that there is no https scheme support on the http-enabled-only site.

    When you browse to the https:// URL the situation is similar - IIS does not allow you to use http endpoint on the https-enabled-only site.

    To handle the issue you better use a single site with two bindings.

    Another (and more complex) option would be using different web.configs for sites: set up separate sites (pointed to separate folders) and use the publishing and web.config transforming tools of the Visual Studio

    0 讨论(0)
  • 2021-02-19 21:57

    I dont't know this query is still active or not but as i checked Please

    Add binding="mexHttpsBinding" also with binding="mexHttpBinding" with different endpoint

    This helps me.

    0 讨论(0)
  • 2021-02-19 22:02

    Add This Code.

    <protocolMapping>
      <add scheme="http"  binding="webHttpBinding" bindingConfiguration="httpWebBinding"/>
      <add scheme="https" binding="webHttpBinding" bindingConfiguration="httpsWebBinding"/>
    </protocolMapping>
    
    0 讨论(0)
  • 2021-02-19 22:03

    I've recreated your scenario and used your web.config to configure endpoints for my test service. Your configuration is ok and works correctly. The part that don't works for you is probably your https configuration in IIS. Make sure you have enabled https access to your service. If you test it with IISExpress from Visual Studio then left click on your project and in the properties window (View -> Properties Window ) select for SSL Enabled = True.

    0 讨论(0)
提交回复
热议问题