encode 怎么能让编码的部分是大写 没编码的不变
如 : http://www.baidu.com?id=编号&url=http://www.sina.com 
http://www.baidu.com?id=%E7%BC%96%e5%8F%Bb7url=http%3A%2F%2Fwww.sina.com

解决方案 »

  1.   

    还真想看看怎么变换!除非你encode后再把他转换成大写吧。
      

  2.   

    试一下去,对了要给分哦
         private string UrlEncode(string value) {
                StringBuilder result = new StringBuilder();            foreach (char symbol in value) {
                    if (unreservedChars.IndexOf(symbol) != -1) {
                        result.Append(symbol);
                    } else {
                        result.Append('%' + String.Format("{0:X2}", (int)symbol));
                    }
                }            return result.ToString();
            }
      

  3.   


    对了,加个声明
    string unreservedChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.~";
      

  4.   

    Response.Redirect("test1.aspx?111="+System.Web.HttpUtility.UrlEncode("中华人明共和国")) ; 
      //建议使用最后如果是从其他的页面获取中文参数没有乱码,那就更简单了 
      string message ="http://localhost/Test/test1.aspx?111="+System.Web.HttpUtility.UrlEncode("中华人明共和国"); 
      http: 
      //你要获取某个页面的返回值的地址" 
      //发送请求 
      HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(message) ; 
      //接受请求 
      HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse() ; 
      Stream receiveStream = myHttpWebResponse.GetResponseStream() ; 
      StreamReader readStream = new StreamReader(receiveStream, System.Text.Encoding.GetEncoding("GB2312")) ; 
      //此为要取页面的返回值输出的返回结果 
      returnValue = readStream.ReadToEnd();