2

我有一个在共享托管环境中部署的 WCF 服务。因此,我必须指定baseAddressPrefixFilters(请参阅此处的答案以了解为什么这是必要的)。设置基地址前缀过滤器发生在 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 ?

4

1 回答 1

0

如果您在 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

于 2009-04-22T20:59:34.383 回答