如何在HttpTransportBindingElement上添加cookie [英] How to add cookie on a HttpTransportBindingElement

查看:217
本文介绍了如何在HttpTransportBindingElement上添加cookie的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 WCF客户端,它与 WCF服务(运行AspNetCompabilityMode)进行通信,我想添加 cookie (在客户端)每次调用此Web服务。

I'm having a WCF client which communicates with a WCF service (running AspNetCompabilityMode), and I would like to add a cookie (on the client) to every call to this web service.

我看过 HttpTransportBindingElement ,但我不能找到在哪里添加cookie - 是否可以向HttpTransportBindingElement添加一个cookie,或者我应该考虑另一种方法吗?

I have looked at the HttpTransportBindingElement, but I cannot find where to add my cookie - is it possible to add a cookie to the HttpTransportBindingElement, or should I consider another approach?

推荐答案

a href =http://kennyw.com/indigo/153 =nofollow noreferrer> http://kennyw.com/indigo/153 在每个服务调用的基础上工作。这意味着您必须确保在创建 OperationContextScope 对象之后之后之前创建对WCF服务的所有调用
为此工作。

The method described in http://kennyw.com/indigo/153 works on a per-service-call basis. This means you have to make sure all invocations to your WCF service are made after the OperationContextScope object is created and before it is disposed for this to work. Otherwise the cookie will never be added to the request.

如果您正在寻找一个集中式解决方案来手动添加cookie到所有发送到WCF服务的传出HTTP请求看看这个线程:

If you are looking for a centralized solution to manually add a cookie to all outgoing HTTP requests made to the WCF service have a look at this thread:

http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/624fb3f9-222d-4795-9140-fe9ef3934361/ < a>

http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/624fb3f9-222d-4795-9140-fe9ef3934361/

这篇关于如何在HttpTransportBindingElement上添加cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆