Friday, September 18, 2009

WCF – Hosting a service in IIS

I have been playing with Silverlight and WCF over the last couple of weeks and today I tried moving the service to my web-host “Verio”. Unfortunately what was working on my local machine – stopped working on web-host’s machine and I was getting 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

The problem is related to how different services can be hosted on the same server and the fact that ASP.Net and WCF are processed by different pipelines. I found that with .Net 3.x, Microsoft added some new configuration elements that allow you to control the addresses used. I dont understand the exact reason that causes the problem, but the following worked for me:

Add the following to your web.config file inside the “system.serviceModel” node:

<serviceHostingEnvironment>
<baseAddressPrefixFilters>
<add prefix="http://www.aggregatedintelligence.com"/>
</baseAddressPrefixFilters>
</serviceHostingEnvironment>

Read more about the baseAddressPrefixFilters at http://msdn.microsoft.com/en-us/library/bb924481.aspx

No comments: