cookies传值发生乱码的问题
protected void LBmorelblmodule1_Click(object sender, EventArgs e)//按钮有如下代码
{
HttpCookie MyCookie = new HttpCookie("lblmodule1");
DateTime now = DateTime.Now;
MyCookie.Value = "商业信息";
MyCookie.Expires = now.AddHours(25);
Response.Cookies.Add(MyCookie);
this.La.Text = MyCookie.Value;//测试显示正常
Response.Redirect("MoreSearch.aspx");
}
提交按钮后
protected void Page_Load(object sender, EventArgs e)
{
HttpCookie MyCookie = Request.Cookies["lblmodule1"];
DateTime now = DateTime.Now;
MyCookie.Expires = now.AddHours(1);
if (MyCookie.Value.ToString() == "" || MyCookie.Value.ToString() == null)
{
this.Label2.Text = "没有读到内容";
this.Page.Title = "没有读到内容";
}
else
{
this.Label2.Text = MyCookie.Value;//显示乱码了,是怎么回事? this.Page.Title = this.Label2.Text;
}
}
问题请看注释红色字体部分