C#如何获取Cookie的值?

//写入
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (Request.Cookies[cookiename] == null)
        {
            HttpCookie cookie = new HttpCookie(cookiename);
            cookie["IP"] = txtIP.Text;
            Response.Cookies.Add(cookie);
        }
        else
        {
            Response.Cookies[cookiename]["IP"] = txtIP.Text;
           // Response.Write("");
        }
       
       
    }
    //读取
    protected void Button2_Click(object sender, EventArgs e)
    {
        HttpCookie cookie = Request.Cookies[cookiename];
        if (cookie!=null)
        {
            txtReadIP.Text = cookie["IP"];
        }
    }


 

你可能感兴趣的:(C#,ASP.Net)