我在 asp.net项目里有asp.net文件与asp文件,其中web.config 文件已设置
<globalization requestEncoding="GB2312" responseEncoding="GB2312"/>
asp.net 页页实现用户登陆
//人员登陆
private void Btn_Login_Click(object sender, System.EventArgs e)
{
string lgname,pwd;
GetData.DataBase rItem = new GetData.DataBase();
lgname = Request.Form["login_name"];
pwd = Request.Form["login_pwd"];
SqlDataReader Dr = rItem.re_LgReader(lgname,pwd) ;
if(Dr.Read())
{
HttpCookie cookie = new HttpCookie("Login");
cookie["Login_Id"] = Dr["member_id"].ToString();
cookie["Login_Name"] = Dr["xingming"].ToString();
this.P_Login.Visible = false;
this.P_unLogin.Visible = true;
Response.Cookies.Add(cookie);
}else{
cqdxy.code.inor its = new cqdxy.code.inor();
its.alert("用户名或密码错误!","");
}
Dr.Close();
}
我在其中一个asp页面内现示 用户信息 (<%= request.Cookies("Login")("Login_Name") %>)是汉字出现乱码,在asp.net 页面内就正常
如果把 asp 页面设为
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
用户信息就正常,其它信息就乱了,有什么方法可以解决这个问题!
<globalization requestEncoding="GB2312" responseEncoding="GB2312"/>
asp.net 页页实现用户登陆
//人员登陆
private void Btn_Login_Click(object sender, System.EventArgs e)
{
string lgname,pwd;
GetData.DataBase rItem = new GetData.DataBase();
lgname = Request.Form["login_name"];
pwd = Request.Form["login_pwd"];
SqlDataReader Dr = rItem.re_LgReader(lgname,pwd) ;
if(Dr.Read())
{
HttpCookie cookie = new HttpCookie("Login");
cookie["Login_Id"] = Dr["member_id"].ToString();
cookie["Login_Name"] = Dr["xingming"].ToString();
this.P_Login.Visible = false;
this.P_unLogin.Visible = true;
Response.Cookies.Add(cookie);
}else{
cqdxy.code.inor its = new cqdxy.code.inor();
its.alert("用户名或密码错误!","");
}
Dr.Close();
}
我在其中一个asp页面内现示 用户信息 (<%= request.Cookies("Login")("Login_Name") %>)是汉字出现乱码,在asp.net 页面内就正常
如果把 asp 页面设为
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
用户信息就正常,其它信息就乱了,有什么方法可以解决这个问题!
你把webconfig里面的三顶全部修改了吗?
cookie["Login_Id"] = HttpUtility.UrlEncode(Dr["member_id"].ToString(),enc);
cookie["Login_Name"] = HttpUtility.UrlEncode(Dr["xingming"].ToString(),enc);