HtmlEncode和HtmlDecode用于Html的编码和解码
UrlEncode和UrlDecode用于Url的编码和解码,如用来编码Cookie里的中文字符号
HttpCookie cookie = new HttpCookie("account");
cookie.Domain = 'ops.cc';
cookie.Expires=DateTime.Now.AddSeconds(cookieSeconds);
cookie.Values.Add("username", account.UserName);
cookie.Values.Add("nickname",HttpUtility.UrlEncode(account.NickName));
HttpCookie cookie = HttpContext.Current.Request.Cookies["account"];
string NickName =HttpUtility.UrlDecode(cookie.Values["nickname"]);