protected void Button1_Click(object sender, EventArgs e)
{
HttpCookie HC = new HttpCookie("aaa", "bbb");
HC.Expires = DateTime.Now.AddDays(10);
Response.Cookies.Add(HC);
} protected void Button2_Click(object sender, EventArgs e)
{
Button2.Text = Request.Cookies.Get("aaa").Value;
}
b1设置 b2 显示,都正常,
但关浏览器后,在开,b2就读不到了。
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.Source Error:Line 24: protected void Button2_Click(object sender, EventArgs e)
Line 25: {
Line 26: Button2.Text = Request.Cookies.Get("aaa").Value;
Line 27: }
Line 28: }
十分纠结,望大家帮忙看看
{
HttpCookie HC = new HttpCookie("aaa", "bbb");
HC.Expires = DateTime.Now.AddDays(10);
Response.Cookies.Add(HC);
} protected void Button2_Click(object sender, EventArgs e)
{
Button2.Text = Request.Cookies.Get("aaa").Value;
}
b1设置 b2 显示,都正常,
但关浏览器后,在开,b2就读不到了。
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.Source Error:Line 24: protected void Button2_Click(object sender, EventArgs e)
Line 25: {
Line 26: Button2.Text = Request.Cookies.Get("aaa").Value;
Line 27: }
Line 28: }
十分纠结,望大家帮忙看看
应该是cookie失效了,你把时间改长一点了