WCF Tutorial
Lesson 119 of 236 · Part 40 How to retrieve the sessionid in WCF service and in the client application · Database
Part 40 How to retrieve the sessionid in WCF service and in the client application
Link for code samples used in the demo
http://csharp-video-tutorials.blogspot.com/2014/03/part-40-how-to-retrieve-sessionid-in_2.html
Link for all dot net and sql server video tutorial playlists
http://www.youtube.com/user/kudvenkat/playlists
In this video, we will discuss retrieving the sessionid in WCF service and in the client application
This is continuation to Part 39. Please watch Part 39 before proceeding. We will work with the same example, that we worked with in Part 39.
In order to send messages from a particular client to a particular service instance on the server, WCF uses SessionId.
There are different types of sessions in WCF. We will discuss these in a greater detail in a later video session.
To retrieve SessionId from the client application use
procyClassInstance.InnerChannel.SessionId property
To retrieve SessionId from the WCF service use
OperationContext.Current.SessionId
The client-side and service-side session IDs are corelated using the reliable session id. So, if TCP binding is being used with reliable sessions disabled then the client and server session id’s will be different. On the other hand, if reliable sessions are enabled, the session id’s will be same.
Enable reliable sessions using the binding element.
With wsHttpBinding, irrespective of whether reliable sessions are enabled or not, the session id’s will be same.