Reputation: 1802
I am hosting WCF Rest service with my Asp.net Application, and asp.net compatibility mode is on ,it is working fine when I run app from visual studio but when I in IIS7 I get error while accessing the End Point says "An item with the same key has already been added." MY Service Cod is.
[ServiceContract]
[AspNetCompatibilityRequirements
(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class RestService
{
[OperationContract]
[WebGet(UriTemplate = "Site/{Id}", BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json)]
public Site GetSite(string Id)
{
return new Site(1);
}
}
and global ASCX is
protected void Application_Start ()
{
RouteTable.Routes.Add(new ServiceRoute("Rest", new WebServiceHostFactory(), typeof(RestService)));
}
and web.config
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
<standardEndpoints>
<webHttpEndpoint>
<standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="false"/>
</webHttpEndpoint>
</standardEndpoints>
</system.serviceModel>
Note Every things working fine in VS2010 Mode but getting error in while Hosting IIS 7 and accessing http://example.com/rest/site/2 any Suggestion Please ?
Upvotes: 4
Views: 4851
Reputation: 1802
In IIS Under Advance Setting then Enabledd Protocols I switched off https and it works fine.
Upvotes: 8