Question

I created a self-hosted WCF data service and as you can see here, I discovered that it does not support the ASP.Net context (HttpContext.Current is null).

Am I correct if I suppose that session handling is also not available in a self-hosted data service?

Was it helpful?

Solution

Session handling is not available in self-hosted WCF Data Services as it utilizies the HttpContext class which relies on ASP.Net context and it is always null in Data Services. So you have to implement a custom solution to imitate session handling in WCF Data Services.

OTHER TIPS

In the self hosted service, you should be able to Use the SessionMode enumeration with the ServiceContractAttribute.SessionMode property to require, allow, or prohibit bindings to use sessions between endpoints that connect to or support the service contract.
For example, if the SessionMode property is set to SessionMode.Allowed and the ServiceBehaviorAttribute.InstanceContextMode property is set to InstanceContextMode.PerSession, a client can use a binding that supports reliable sessions to make repeated calls to the same service object. If your service supports sessions, you can then use the `ServiceBehaviorAttribute.InstanceContextMode' property to specify the relationship between instances of your service contract implementation and the channel session.

The following links provide good reference information:
http://msdn.microsoft.com/en-us/library/ff183865.aspx
http://msdn.microsoft.com/en-us/library/system.servicemodel.sessionmode.aspx

Regards,

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top