js 转码 和 .Net 后台解码

为防止 中文乱码,js传值要转码,当js 用 escape() 转码时,.Net 后台可以用 HttpUtility.UrlDecode() 进行解码。

例如:

  document.cookie = "city=" +escape($(this).html());
  string city = HttpUtility.UrlDecode(HttpContext.Current.Request.Cookies["city"].Value);

posted @ 2015-11-13 15:34  awake-insist  Views(442)  Comments(0Edit  收藏  举报