从在的WebHttpBinding WCF服务访问会话 [英] Access Session in WCF service from WebHttpBinding
问题描述
我使用WCF服务(通过WebGet属性)。
I'm using WCF service (via WebGet attribute).
我试图从WCF服务访问会话,但HttpContext.Current为null
I'm trying to access Session from WCF service, but HttpContext.Current is null
我添加AspNetCompatibilityRequirements和编辑的web.config,但是我仍然无法访问会话。
I added AspNetCompatibilityRequirements and edited web.config but I still cannot access session.
是否有可能使用WebGet和Session在一起吗?
Is it possible to use WebGet and Session together?
感谢您!
推荐答案
是的,这是可能的。如果编辑的web.config
:
Yes, it is possible. If you edit the web.config
:
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
</system.serviceModel>
和添加 AspNetCompatiblityRequirements
的 HttpContext.Current
应该可用。
再次检查一切,也许你放错了地方的属性(接口而不是类的?)。
Check everything once again, maybe you've put the attribute in the wrong place (the interface instead of the class?).
这篇关于从在的WebHttpBinding WCF服务访问会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!