简体   繁体   English

手动处理WCF会话超时

[英]Manually Handling WCF Session Timeout

I am manually maintaining WCF Session. 我正在手动维护WCF会话。 When client login a GUID is given to the client as sessionId. 客户端登录时,会将GUID作为sessionId给予客户端。 All others methods have sessionId as parameter that client will provide. 所有其他方法都将sessionId作为客户端将提供的参数。 Every thing working fine. 一切正常。 Now how can i manually manage Session Timeout ? 现在如何手动管理会话超时?

Let's first get the fact that you are trying to maintain state between WCF calls, which rather violates the principle in the first place, out of the way first. 首先让我们得到一个事实,您正在尝试维护WCF调用之间的状态,这首先违反了该原则,而不是首先破坏了该原则。 (Take a look at the question: Manually Handling WCF Session Timeout ) (看看问题: 手动处理WCF会话超时

Assuming that you are generating the guid that is the sessionid then you'll need to store that somewhere, a database seems likely. 假设您正在生成的GUID是sessionid,那么您需要将其存储在某个地方,数据库似乎很可能会出现。 Store the sessionID there with the current DateTime. 将sessionID与当前的DateTime存储在那里。 Each time a request is received, check the store for the sessionID and see if your timeout has been exceeded, if so the dispose of the sessionID and report the state back to the client. 每次收到请求时,请在商店中获取sessionID,并查看是否超出了您的超时时间(如果超过),请处置sessionID,并将状态报告给客户端。 If the timeout has not been exceeded then update the DateTime to the now current DateTime and process the request. 如果未超过超时,则将DateTime更新为当前的DateTime并处理请求。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM