WCF:如何检测会话超时?

时间:2021-12-17 19:39:46

I write this Interface to create and terminating a session.

我编写此接口来创建和终止会话。

 [ServiceContract(SessionMode = SessionMode.Required)]
  public interface IOrdersService
  {
    [OperationContract(IsInitiating = true, IsTerminating = false)]
    void EmptyCart();

    [OperationContract(IsInitiating = false,IsTerminating = false)]
    void AddToCart(CartItem cartItem);
   }

it`s work fine. But when a session timeout then how can i detect ??

它工作得很好。但是当一个会话超时时,我怎么能检测到?

1 个解决方案

#1


1  

If it is trimmed out, your channel will be faulted both on your client and your server's callback channel, you can listen on faulted event on channel. And once it is faulted, you will need to recreate a channel to recover.

如果它被裁掉,您的频道将在您的客户端和服务器的回叫频道上出现故障,您可以在频道上收听故障事件。一旦出现故障,您将需要重新创建一个恢复通道。

#1


1  

If it is trimmed out, your channel will be faulted both on your client and your server's callback channel, you can listen on faulted event on channel. And once it is faulted, you will need to recreate a channel to recover.

如果它被裁掉,您的频道将在您的客户端和服务器的回叫频道上出现故障,您可以在频道上收听故障事件。一旦出现故障,您将需要重新创建一个恢复通道。