When trying to access a WCF .svc file you may get 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
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
The solution, since WCF services hosted in IIS can have only one Base Address was to create a custom service factory to intercept and remove the additional unwanted base addresses that IIS was providing. In my case IIS was providing:
We are able to customize our .svc file to specif a custom serive factory
We are then able to create our custom factory by inheriting from ServiceHostFactory and overriding as required
CustomHostFactory : ServiceHostFactory
ServiceHost CreateServiceHost(Type serviceType, Uri baseAddresses)
CustomHost customServiceHost =
CustomHost : ServiceHost
In your case, you can decided to pass through baseAddresses (which was the www. address) but it would probably be wise to specify that address you want to prevent changes by your web host from impacting your code.