BeFruit

Monday, September 8, 2008

WCF error: "This collection already contains an address with scheme http"

I met this error, and wondered what this could be. The explanation is that "WCF services hosted in IIS can have only one Base Address", meaning that in IIS the website hosting the service can not be associated to http://www.example.com and http://example.com at the same time.

I don't know why this prevents a service to work, but I know this is annoying.
I found a couple of bloggers like Rob suggesting a solution with a coded custom ServiceHostFactory, which sounds terribly complicated to me as a workaround.

Fortunately there is a much simpler solution, just by touching the web.config file. Just add the following lines in the system.serviceModel section:
<serviceHostingEnvironment>

    <baseAddressPrefixFilters>

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

    </baseAddressPrefixFilters>

</serviceHostingEnvironment>

to only keep the service address.

Labels:

17 Comments:

Post a Comment



<$I18N$LinksToThisPost>:

Create a Link

<< Home