问题描述
在页面加载,如果你这样做Response.Cookies.Add(...,立即在下一行,您可以通过Request.Cookies时(访问饼干...
In pageload, if you do Response.Cookies.Add(..., immediately in the next line, you can access that cookie via Request.Cookies(...
我知道在幕后,该Cookie是由.NET加入到Request.Cookies时,但原来的要求从未有过的饼干。
I know that under the covers, the cookie is added to Request.Cookies by .net, but the original request never had that cookie.
如果我在说什么是正确的,为什么会这样?应该不是饼干可在下面的请求?如果不Request.Cookies时(...的即时访问为空?
If what I'm saying is correct, why is it this way? Shouldn't the cookie be available in the following request? Shouldn't the immediate access to Request.Cookies(... be null?
推荐答案
您说得对,确实ASP.NET做幕后:
You're right, ASP.NET does do that behind the scenes:
您后,使用添加一个cookie
<一href=\"http://msdn.microsoft.com/en-us/library/system.web.htt$p$psponse.cookies.aspx\"><$c$c>Htt$p$psponse.Cookies$c$c>收藏,
Cookie是在立即可
的Htt prequest.Cookies
收集,甚至
如果响应没有被发送到
客户端
- <一href=\"http://msdn.microsoft.com/en-us/library/system.web.htt$p$pquest.cookies.aspx\">Htt$p$pquest.Cookies在MSDN页面
为什么会这样呢?在猜测,这是因为这是开发人员如何期望它的工作。
Why is it like that? At a guess, it's because that's how developers expect it to work.
这篇关于为什么饼干中要求提供的使用设定的响应后,立即?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!