Tadej
Tadej

Reputation: 298

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

Upvotes: 4

Views: 7980

Answers (4)

Abyte0
Abyte0

Reputation: 969

2023-12-08 I had this same exact error with IIS10 after renewing my certificates for one of my websites.

It was the first time I had this problem over at least 20 certificate renew process I've done so far.

Here was the solution to my problem:

Deleted all the https bindings of my website and remade them exactly identical.

Upvotes: -1

Tadej
Tadej

Reputation: 298

Problem solved.

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

   <serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>

Upvotes: 0

Vijunav Vastivch
Vijunav Vastivch

Reputation: 4211

Check:

  1. Web.Config elements it could be possible duplicate.
  2. Check also whether it is 32 or 64 bit application in IIS.
  3. Application pools framework.

Upvotes: 0

user6996876
user6996876

Reputation:

A possible cause is

  1. Your IIS web application's advanced settings indicates "http,https" in "Enabled Protocols".
  2. The "Default Web Site"'s "Site Bindings" does not have an https binding type.

See https://stackoverflow.com/a/19440427/6996876

Upvotes: 12

Related Questions