I'm using WCF service (via WebGet attribute).
I'm trying to access Session from WCF service, but HttpContext.Current is null
I added AspNetCompatibilityRequirements and edited web.config but I still cannot access session.
Is it possible to use WebGet and Session together?
Thank you!
WCF sessions have the following main conceptual features: They are explicitly initiated and terminated by the calling application (the WCF client). Messages delivered during a session are processed in the order in which they are received. Sessions correlate a group of messages into a conversation.
WCF manage session by creating the instance of the service class. These created instance(s) handle the incoming service request. In WCF, session is the way of managing the services instance(s) so that server can used these instances in an optimized way.
Yes, it is possible. If you edit the web.config
:
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
</system.serviceModel>
and add the AspNetCompatiblityRequirements
, the HttpContext.Current
should be available.
Check everything once again, maybe you've put the attribute in the wrong place (the interface instead of the class?).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With