gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 20:53:56 25 4
gpt4 key购买 nike

在服务器端,当我收到一个 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com