Search code examples
c#asp.net-mvcwcfiisbinding

WCF - An item with the same key has already been added


I keep getting an error when trying to open WCF WebService via http://www.example.com/WS/myExchange.svc:

System.ArgumentException An item with the same key has already been added.

System.ArgumentException: An item with the same key has already been added. at System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result) at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) at System.ServiceModel.Activation.ServiceHttpModule.EndProcessRequest(IAsyncResult ar) at System.Web.HttpApplication.AsyncEventExecutionStep.OnAsyncEventCompletion(IAsyncResult ar)

When I open the same WS on the localhost, everything works normally.

I don't even know where to start searching for the root of the problem.

Is the problem in IIS configuration, installed modules, project code?

How to find out which item with the same key has already been added? Even if is it in Web.Config? In code? In database? In included modules?

Problem appears only on "/WS/myExchange.svc", other parts of the website work normally.

Advanced settings: enter image description here

Site bindings: enter image description here


Solution

  • Problem solved.

    In Web.Config, section system.serviceModel I had to add:

       <serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>