Search This Blog

Loading...

Sep 7, 2010

Session in WCF


Sponsored Links:
WCF Session is different with Asp.net session so don’t get confused. Here session means. to combine several message together into single conversation. They are initiated from the calling application, in other word’s they
are client side and they can not store any kind of data inside.
Session are set by SessionMode” Attribute.
[ServiceContract (SessionMode = SessionMode.Required)]
Following enumeration value’s are possible for this attribute.



  1. Allowed: Specifies the contract supports the reliable sessions if the incoming connection supports them. Here Session can be allowed.
  2. Not Allowed: Contract never supports reliable sessions.
  3. Required: Specifies that the contract requires a reliable sessions at all time. Means session is mandatory.
Now if your endpoints support session in that case session will work. In other words it is not supported by BasicHttpBinding to obtain this functionality you have to choose either   wsHttpBinding or NetTcpBinding.
One More thing if your exception is not handle properly session will be destroyed along with that with exception but if it is handled by FaultException at the service end then it will works fine for subsequent methods calls.

Follow by Email