WCF (REST) multiple host headers with one endpoint
- by Maan
I have an issue with a WCF REST service (.NET 4) which has multiple host headers, but one end point.
The host headers are for example:
xxx.yyy.net
xxx.yyy.com
Both host headers are configured in IIS over HTTPS and redirect to the same WCF service endpoint.
I have an Error Handling behavior which logs some extra information in case of an error.
The problem is that the logging behavior only works for one of both URLs. When I first call the .net URL, the logging is only working for requests on the .net URL. When I first call the .com URL (after a Worker Process recycle), it’s only working on requests on the .com URL.
The configuration looks like this:
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
<services>
<service name="XXX.RemoteHostService">
<endpoint address="" behaviorConfiguration="RemoteHostEndPointBehavior" binding="webHttpBinding" bindingConfiguration="HTTPSTransport" contract="XXX.IRemoteHostService" />
</service>
</services>
<extensions>
<behaviorExtensions>
<add name="errorHandling" type="XXX.ErrorHandling.ErrorHandlerBehavior, XXX.Services, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
</behaviorExtensions>
</extensions>
<bindings>
<webHttpBinding>
<binding name="HTTPSTransport">
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
</binding>
</webHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="RemoteHostEndPointBehavior">
<webHttp />
<errorHandling />
</behavior>
</endpointBehaviors>
</behaviors>
….
Should I configure multiple endpoints? Or in which way could I configure the WCF Service so the logging behavior is working for both URLs?
I tried several things, also solutions mentioned earlier on StackOverflow. But no luck until now...