是否可以在 wcf 服务的 OperationContract 中读取 cookie?我正在尝试在合同方法中读取 cookie 值,但它始终为空。如果我从 .aspx 页面读取相同的 cookie,则该值存在。有任何想法吗?
问问题
1181 次
2 回答
1
你是如何招待他们的?WCF 旨在与主机无关——即,在 IIS 之外托管时,您的服务应该仍然可以工作。但是,有一种兼容模式可以帮助您:
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
</system.serviceModel>
默认值为 false 并禁用大多数 ASP.NET 功能,如 HttpContext.Current。
于 2010-09-15T18:25:04.080 回答
1
BasicHttpBinding.AllowCookies 属性可能会解决此问题,如Enrico的博客文章的开头所述,该文章关于在 WCF 中管理共享 cookie (在此处引用)。该帖子包括 web.config 片段:
<system.ServiceModel>
<bindings>
<basicHttpBinding allowCookies="true">
</bindings>
<client>
<endpoint address="http://localhost/myservice"
binding="basicHttpBinding"
contract="IMyService" />
</client>
</system.ServiceModel>
但没有使用它的代码片段(博客文章包含使用相同 cookie 和不同 Web 服务的更复杂解决方案的代码)。
======== 编辑 ==========
于 2012-03-03T12:10:43.617 回答