Configuring a WCF Service with IIS 7, .NET 3.5 or .NET 4.0

When you deploy a WCF service in a shared hosting environment you may receive the following error:

This collection already contains an address with scheme http.  There can be at most one address per scheme in this collection. Parameter name: item


To apply the fix open the web.config file for the service within Visual Studio and within the <system.serviceModel> tags add the following XML:

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

Once these lines are added, redeploy the service and refresh the service in the browser.   The error should now be gone.

Article ID: 296, Created On: 8/24/2010, Modified: 8/24/2010