WebHttpBinding with Http and Https

前端 未结 4 2091
予麋鹿
予麋鹿 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

提交回复
热议问题