【问题标题】:How can I host 2 WCF self hosted services using different host names on the same machine (using the host header)如何在同一台机器上使用不同的主机名托管 2 个 WCF 自托管服务(使用主机标头)
【发布时间】:2017-02-15 15:58:39
【问题描述】:

我正在尝试使用以下 url 约定自行托管两个 WCF 服务:

https://service.servicehost.com/service

https://service-branch.servicehost.com/service

我得到这个错误:

服务无法启动。 System.ServiceModel.AddressAlreadyInUseException:HTTP 无法 注册网址https://+:443/service/。另一个应用程序已经 用 HTTP.SYS 注册了这个 URL。 --->

我了解该错误,并且知道如何通过更改服务的后缀来解决此问题,但 WCF 自身主机似乎不像 IIS 那样支持主机标头功能(因为我看到了 + 号)。

有什么办法可以实现吗?

【问题讨论】:

    标签: wcf self-hosting


    【解决方案1】:

    我不确定这是否可以用于 SelfHost/Http。使用 Net.Tcp,您将不得不使用 PortSharing 来实现这一点。

    在最坏的情况下,您可能会创建一个 Routing Service,将您的请求路由到正确的服务,每个服务都在不同的端口上侦听。

    另外,请查看HostNameComparisonMode Enumeration 的文档。 basicHttpBinding 的文档将向您展示如何使用它。

    【讨论】:

    • hostNameComparisonMode="Exact" 添加到绑定配置似乎可以解决这个问题。谢谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多