I manage a shared cookie when making WCF service calls using this methodology described in the heading << → Centralized cookie management ": http://megakemp.com/2009/02/06/managing-shared-cookies-in-wcf /
I created a custom IClientMessageInspector, IEndpointBehavior, BehaviorExtensionElement, work. My endpoint behavior is added by the message inspector as follows:
public class MyEndpointBehavior : IEndpointBehavior
{
public void AddBindingParameters(ServiceEndpoint endpoint, System.ServiceModel.Channels.BindingParameterCollection bindingParameters)
{
}
public void ApplyClientBehavior(ServiceEndpoint endpoint, System.ServiceModel.Dispatcher.ClientRuntime clientRuntime)
{
clientRuntime.MessageInspectors.Add(new MyClientMessageInspector());
}
public void ApplyDispatchBehavior(ServiceEndpoint endpoint, System.ServiceModel.Dispatcher.EndpointDispatcher endpointDispatcher)
{
}
public void Validate(ServiceEndpoint endpoint)
{
}
}
Everything works flawlessly , but this solution breaks when you want to share cookies over multiple clients. Since the method ApplyDispatchBehavior()creates a new instance, any other client will not receive the message inspector instance, and thus the auth ticket.
, , :
MyEndpointBehavior(MyClientMessageInspector msgInspector) { ... }
WCF . , WCF , , IInstanceProvider, IServiceBehavior .. , , .
- ?