【问题标题】:dynamically set WCF baseAddressPrefixFilters动态设置 WCF baseAddressPrefixFilters
【发布时间】:2009-04-22 20:13:04
【问题描述】:

我在共享托管环境中部署了 WCF 服务。因此,我必须指定baseAddressPrefixFilters(请参阅答案here 了解为什么这是必要的)。设置基地址前缀过滤器发生在 web.config 中,如下所示...

<serviceHostingEnvironment>
  <baseAddressPrefixFilters>
    <add prefix="http://example.com"/>
  </baseAddressPrefixFilters>
</serviceHostingEnvironment>

问题是我有多个环境以这种方式配置有自己的 url(即 dev、test、prod)

我尝试了以下没有运气...

<serviceHostingEnvironment>
  <baseAddressPrefixFilters>
    <add prefix="http://dev.example.com"/>
    <add prefix="http://test.example.com"/>
    <add prefix="http://example.com"/>
  </baseAddressPrefixFilters>
</serviceHostingEnvironment>

那么问题是如何在运行时动态设置baseAddressPrefixFilter?

【问题讨论】:

    标签: c# asp.net wcf wcf-binding


    【解决方案1】:

    如果您在 IIS7 下运行,这是一个很好的问题和解决方案演练。如果没有,WCF 方面的信息仍然是您解决问题所需要知道的。

    http://keithelder.net/2008/04/28/configuring-wcf-and-iis-7-with-http-bindings-and-multiple/

    您看过 ServiceHostFactory 吗?我们在 3.0 服务中使用它来处理不同的主机头。

    http://blogs.msdn.com/rampo/archive/2007/06/15/supporting-multiple-iis-bindings-per-site.aspx

    【讨论】:

    • 感谢您的回复。不幸的是,环境是 IIS6,我正在寻找运行时解决方案而不是服务器配置解决方案,因为它是一个共享托管环境。
    • 这似乎是目前最好的方法。将其标记为答案。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-04-21
    • 1970-01-01
    相关资源
    最近更新 更多