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.
精彩评论