c# - Response.cookies出现在request.cookies中

标签 c# .net

在服务器端,当我收到 http 请求时,我添加一个新的 cookie,如下所示:

HttpContext.Response.Cookies.Add(it);

如果我立即在 HttpContext.Request.Cookies 中查询我刚刚添加的 cookie 的名称,我会得到它,尽管我认为我不应该,因为我什至还没有完成我的请求处理,没有发送尚未回复客户。

请求和响应的 cookie 集合是否应该彼此不同?就像 http 请求/响应 cookie header 一样。

谢谢

最佳答案

这是预期的且有据可查的行为。请参阅HttpResponse.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.

关于c# - Response.cookies出现在request.cookies中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19557365/

相关文章:

c# - 如何设置 ffmpeg 管道输出?

c# - Resharper - 在 C# 中使用 'help' 快捷方式时禁用 "prop"

C# - 为应用程序保留磁盘内存(存储)

c# - LINQ问题我想获取每个寄存器的表的最后记录

.net - 关于第 3 方集成商的 wcf 服务的问题

.net - 如何在 clr.dll 或 mscoree.dll 中调试

.net - 如何添加 NHibernate 配置文件以使用 NHibernate.Search?

c# - 无法将类转换为 ObservableCollection

c# - 如何在用户每次完成笔划时进行手写识别?

c# - Entity Framework 4.1 - 代码优先 : many-to-many relationship