문제

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?

도움이 되었습니까?

해결책

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.

다른 팁

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,

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top