Response.cookies出现在Request.Cookies时 [英] Response.cookies show up in request.cookies

查看:301
本文介绍了Response.cookies出现在Request.Cookies时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在当我收到一个HTTP请求,我加入这样一个新的Cookie在服务器端:

On the server side when I received an http request, I am adding a new cookie like this:

HttpContext.Response.Cookies.Add(it);

如果我立刻查询HttpContext.Request.Cookies因为我刚添加的cookie的名字,我找回来,虽然我觉得我不应该因为我连我的要求做了处理,没送响应客户呢。

If I immediately query the HttpContext.Request.Cookies for the name of the cookie I just added, I get it back, although I think I Shouldn't since I am not even done with my request handling, did not send the response to client yet.

如果请求的响应和的Cookie集合是不同的对方?就像HTTP请求/响应的cookie头。

Should the Request's and Response's cookie collections be different of each other? Just like http request/response cookie headers.

感谢

推荐答案

这是预料之中的有据可查的行为。请参见的Htt presponse.Cookies < /一>:

This is expected and well documented behavior. See HttpResponse.Cookies :

在使用的Htt presponse.Cookies集合添加一个cookie,该cookie是立即在Htt的prequest.Cookies收集可用,即使响应尚未发送给客户端。

After you add a cookie by using the HttpResponse.Cookies collection, the cookie is immediately available in the HttpRequest.Cookies collection, even if the response has not been sent to the client.

这篇关于Response.cookies出现在Request.Cookies时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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