利用Cookie变量来存储信息和服务器页面
获取IP地址:
代码如下:
protected void Button3_Click(object sender, EventArgs e)
{
string userIP = Request.UserHostAddress.ToString();
Response.Cookies["IP"].Value = userIP;//给cookies赋值
}
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = Request.Cookies["IP"].Value;//获取cookies的值
}