当前位置: 代码迷 >> ASP.NET >> cookie的有关问题,请大家帮忙。
  详细解决方案

cookie的有关问题,请大家帮忙。

热度:4909   发布时间:2013-02-25 00:00:00.0
cookie的问题,请大家帮忙。。。
TB_username.Text 内容是 "林先生 "
pcookie.Values.Add( "UserName ",Server.UrlEncode(TB_username.Text));
写入后,

labusername.Text   =   Server.UrlDecode(Request.Cookies[ "Shop "].Values[ "UserName "].ToString());

显示的信息却是乱码加后面?   flux_stat_user=0.48070000   118916024213557376

鏋楀厛鐢?   flux_stat_user=0.48070000   118916024213557376

------解决方案--------------------------------------------------------
楼主,看了你的内容,我也照着跑了一下程序,好象没问题
代码下边

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
HttpCookie UserCookie = new HttpCookie( "User ");
UserCookie.Values.Add( "UserName ", Server.UrlEncode( "林先生 "));
Response.Cookies.Add(UserCookie);
}
protected void Button1_Click(object sender, EventArgs e)
{
string aa = Server.UrlDecode(Request.Cookies[ "User "].Values[ "UserName "].ToString());
}
}

aa的值没问题.
------解决方案--------------------------------------------------------
KOOKIE里头最好不要保存中文
  相关解决方案