本文介绍了修改Response.Cookies集合也改变Request.Cookies在.Net?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只要检查我看到的内容,修改Response.Cookies集合也会更改Request.Cookies?

Just want to check what i'm seeing, modifying the Response.Cookies collection also changes Request.Cookies?

推荐答案

是的,它确实。尝试创建一个新的页面与代码中的以下:

Yes, it does. Try creating a new page with the following in the codebehind:

protected void Page_Load(object sender, EventArgs e)
{
    if (Request.Cookies["newCookie"] == null)
    {
        Response.Cookies["newCookie"].Value = "Hello, world!";
        var myValue = Request.Cookies["newCookie"].Value;
    }
}

清除Cookie并在结尾括号上放置断点的条件。您会在第一个上看到 myValue 的值为Hello,world! >请求。

Clear your cookies and place a breakpoint on the closing brace of the condition. You'll see that myValue has the value "Hello, world!" on the first request.

这篇关于修改Response.Cookies集合也改变Request.Cookies在.Net?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 05:43