是否可以读取wcf服务的OperationContract中的cookie?我正在尝试读取contract方法中的Cookie值,但它总是空的。如果我从.aspx页面读取相同的cookie,则该值存在。有什么想法吗?
发布于 2010-09-16 02:25:04
您是如何托管它们的?WCF应该是与主机无关的--也就是说,当托管在IIS之外时,您的服务应该仍然可以工作。但是,有一种兼容性模式可能会对您有所帮助:
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
</system.serviceModel>默认值为false,会禁用HttpContext.Current等大多数ASP.NET功能。
发布于 2012-03-03 20:10:44
BasicHttpBinding.AllowCookies Property可能会修复这个问题,正如Enrico在Managing shared cookies in WCF上的博客文章(参考here)的开头所提到的那样。该文章包括web.config片段:
<system.ServiceModel>
<bindings>
<basicHttpBinding allowCookies="true">
</bindings>
<client>
<endpoint address="http://localhost/myservice"
binding="basicHttpBinding"
contract="IMyService" />
</client>
</system.ServiceModel>但是没有使用它的代码片段(博客文章有更复杂的解决方案的代码,使用相同的cookie和不同的web服务)。
========编辑==========
或者甚至是allowCookies=false
https://stackoverflow.com/questions/3720505
复制相似问题