Querystring encoding

  //  encoding querystring

  string id = "1";
  string name = "foo#";
  string url = string.Format("foo.aspx?{0}&{1}", Server.UrlEncode(id), Server.UrlEncode(name));
  Response.Redirect(url);

  // decoding can be done using it's counter part HttpServerUtility.UrlDecode()

  string id = Server.UrlDecode(Request.QueryString["id"]);
  string name = Server.UrlDecode(Request.QueryString["name"]);

原文地址:https://www.cnblogs.com/greencolor/p/1669277.html