views:

1004

answers:

1

I have a WCF service that I am deploying in a shared hosting environment. Because of this I have to specify baseAddressPrefixFilters (see answer here for why this is necessary). Setting the base address prefix filters happens in the web.config like so...

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

The problem is that I have multiple environments that are configured this way with their own urls (i.e. dev, test, prod)

I tried the following with no luck...

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

So the question is how do I set the baseAddressPrefixFilter dynamically at runtime?

A: 

If you are running under IIS7, this is a good walk through of the problem and solution. If not, the information for the WCF side is still what you need to know to resolve your issues.

http://www.keithelder.net/blog/archive/2008/04/28/Configuring-WCF-and-IIS-7-With-HTTP-Bindings-and-Multiple.aspx

Have you looked at the ServiceHostFactory? We used this in our 3.0 services to work with the different host headers.

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

Brian ONeil
thanks for the reply. unfortunately the environment is IIS6 and I'm looking for a runtime solution rather than a server config solution since it is a shared hosting environment.
EricAppel
updated my answer...
Brian ONeil
this seems to be the best approach right now. going to mark this as the answer.
EricAppel