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"]);

posted @ 2010-02-19 00:07  greencolor  阅读(159)  评论(0编辑  收藏  举报