BaseAddress will be ignored when WCF hosted in IIS

Published on Tuesday, August 2, 2011
wcf

The baseAddress element will be ignored when WCF hosting in IIS.

The following is an example of WCF config:

<?xml version="1.0" encoding="utf-8" ?> 
<configuration> 
  <system.serviceModel> 
    <services> 
      <service name="xxx.xxx.xxx"> 
        <host> 
            <baseAddresses> 
            <add baseAddress="http://localhost/blah" /> 
            </baseAddresses> 
        </host> 
        <endpoint �. /> 
        <endpoint � /> 
      </service> 
    </services> 
  </system.serviceModel> 
</configuration>

the baseAddresse element will be completely ignored if your WCF hosted in IIS. The base address will be determined by the web site and virtual directory into which your WCF service is placed.

Also, if using self-hosting, baseAddress is not required either.

In some cases, if you provide base address, all other endpoints can use relative address which relative to the base address.