set-cookie头随着多个cookie [英] Set-Cookie Header With Multiple Cookies

查看:182
本文介绍了set-cookie头随着多个cookie的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我面临的一个问题。

当您添加多个设置Cookie 头到响应

headers.Add("Set-Cookie", "a=b;Path=/;");
headers.Add("Set-Cookie", "c=d;Path=/;");

实际上它们被组合,只有一个头用逗号分隔的cookie发送

actually they are combined and only one header is sent with comma-separated cookies

Set-Cookie: a=b;Path=/;,c=d;Path=/;

根据 RFC2109 它是一个有效的语法。
但它不是根据 RFC6265 ,该德precates RFC2109

According to RFC2109 it is a valid syntax. But it is not according to RFC6265, which deprecates RFC2109

此外最新的浏览器不支持此逗号分隔的语法为好。测试在 IE9 火狐13 谷歌浏览器20

Moreover latest browsers does not support this comma-separated syntax as well. Tested on IE9, Firefox 13 and Google Chrome 20.

所有这些浏览器只用了第一个cookie。

All of these browsers took first cookie only.

请参见下面的

https://github.com/mnaoumov/cookie-bug/

我想找到一些解决办法。

I want to find some workaround.

我希望有两个不同的设置Cookie 头。

I expect to have two different Set-Cookie headers.

我试着写一些 MessageInspector 重写HTTP标头。我怎么也找不到访问标头。

I tried to write some MessageInspector to rewrite HTTP headers. I could not find how to access that headers.

任何想法?

P.S。使用的技术:网络API

P.S. Used technology: Web API

推荐答案

据回答的 codePLEX (<一个href=\"http://aspnetwebstack.$c$cplex.com/workitem/288\">http://aspnetwebstack.$c$cplex.com/workitem/288)这个问题是已知问题以及与WCF自托管,并应通过迁移到IIS托管是固定的。

According to answer on codeplex (http://aspnetwebstack.codeplex.com/workitem/288) this issue is known issue and related to WCF self-hosting and should be fixed by moving to IIS hosting.

这是WCF其标记为 4的问题不会解决

找到具有相同的结果<一个另一个问题href=\"http://stackoverflow.com/questions/10221211/wcf-4-0-cookie-only-first-is-recorded-by-browser/11706532\">WCF 4.0 Cookie的只有第一种是通过浏览器记录。

Found another question with the same outcome WCF 4.0 Cookie Only First is Recorded by Browser.

这篇关于set-cookie头随着多个cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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