简体   繁体   中英

Manually Handling WCF Session Timeout

I am manually maintaining WCF Session. When client login a GUID is given to the client as sessionId. All others methods have sessionId as parameter that client will provide. 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. (Take a look at the question: Manually Handling WCF Session Timeout )

Assuming that you are generating the guid that is the sessionid then you'll need to store that somewhere, a database seems likely. Store the sessionID there with the current 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. If the timeout has not been exceeded then update the DateTime to the now current DateTime and process the request.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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