设置的时候进行 Server.UrlEncode()编码 取出解码

解决方案 »

  1.   

    try:
    return Server.UrlDecode(System.Web.HttpContext.Current.Request.Cookies["DvForum"].Values["username"]);
      

  2.   

    编码的一进一出 格式要统一
    举个例子
      HttpContext.Current.Response.Charset = "utf-8";.... HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8;
      

  3.   

    写 if (dt.Rows.Count != 0)
            {
                HttpCookie MyCookie = new HttpCookie("DvForum");
                MyCookie.Values["username"] = HttpUtility.UrlDecode(u.LoginName, System.Text.Encoding.GetEncoding("GB2312"));
                //MyCookie.Values["username"] = u.LoginName;
                MyCookie.Values["password"] = dt.Rows[0]["TruePassWord"].ToString();
                MyCookie.Values["userid"] = dt.Rows[0]["userid"].ToString();
                MyCookie.Values["isMaster"] = dt.Rows[0]["isMaster"].ToString();
                MyCookie.Path = "/";
                System.Web.HttpContext.Current.Response.Cookies.Add(MyCookie);
                return true;
            }

        public static string UserName
        {
            //get { return _CookieValue().Split(',')[1].ToString(); }        get
            {
                try
                { return System.Web.HttpContext.Current.Request.Cookies["DvForum"].Values["username"]; }
                catch
                {
                    return "";
                }
            }
        }help!!!!!!!!!!!!!!
      

  4.   

    这都是类里的
    用不了Server
      

  5.   

    引用 System.Web DLL
    System.Web.HttpUtility.UrlDecode
    System.Web.HttpUtility.UrlEncode