网站编码格式是utf-8  <globalization responseEncoding="utf-8" requestEncoding="utf-8"/> 
如果我在IE7里面直接输入http://localhost/List.aspx?name=我们 (不对name参数值进行编码)
这样带中文参数的网址.用Request["name"] 或Request.QueryString["zixunName"]等等.都取不到正确的值 
. 我不想改变网站的编码格式. 

解决方案 »

  1.   

    你可以用UrlEncode,UrlDecode来做。
      

  2.   


    Uri.UnescapeDataString(Request["name"])
      

  3.   

    你用Request[]肯定取不到正确的东西了,因为你提交的东西没编码,而Request[]在处理时候是按指定的编码去解的
    你想要取原始的未编码的东西就得把Request.RawUrl自己拿去分离出参数名及值,因为RawUrl是没有被解码的原始内容
      

  4.   

    正常的做法都是用UrlEncode编码后再UrlDecode解码也可以试试楼上的做法
      

  5.   

    4楼的做法还是不行啊。我把Request里面的属性值等基本都看了。都没有 "我们" 这个词或者 是"我们" 编码后的值啊。
      

  6.   

    3楼的做法也不行啊,用Request取到的都是乱码 而不是说被编码了。如果是被编码了,肯定可以解码的。
      

  7.   

    http://www.cnblogs.com/onlyendure/archive/2008/03/25/1121247.html
      

  8.   

    我是叫你拿 Request.RawUrl 这个原始的地址去自己分离出要用的参数
    Request[] 里的东西都是解码了的,如果客户端提交的编码和服务器的解码不匹配,那里面的值就是乱码
      

  9.   

            private NameValueCollection QueryStringEx(string rawurl)
            {
                if (!Uri.IsWellFormedUriString(Request.RawUrl, UriKind.Absolute))
                {
                    rawurl = Uri.UnescapeDataString(Request.RawUrl);
                }            if (rawurl.Contains("?"))
                {
                    string[] ss = rawurl.Split(new char[] { '?' }, StringSplitOptions.RemoveEmptyEntries);
                    if (ss.Length > 0)
                    {
                        NameValueCollection nvc = HttpUtility.ParseQueryString(ss[1]);
                        return nvc;
                    }
                }            return null;
            }        protected void Page_Load(object sender, EventArgs e)
            {            NameValueCollection qs = QueryStringEx(Request.RawUrl);
                Response.Write(qs["q"]);
            }http://xxx/?q=%E6%88%91%E7%88%B1%E4%B8%AD%E5%9B%BD
    http://xxx/?q=我爱中国
    看看效果如何
      

  10.   

    几个参数有点问题,自己改正啦
    反正思路就是先检查Url有无被转义,有的话先转正,没有的就直接分离生成命名集供使用
      

  11.   


    感谢你这么有诚意的帮我解决问题.你的方法我都试了,还是没能解决问题,主要问题是Request.RawUrl的值的参数部分是���� 这样的乱码,而不是被转义过的.
      

  12.   

    Momoass 能留个你的QQ号码吗?
      

  13.   


    这个方法可行? 
    能加下你QQ吗?我QQ286557139
      

  14.   

    正常的做法都是用UrlEncode编码后再UrlDecode解码 
      

  15.   

    用urlencode
    dim a as string=server.urlencode(request("name"))
      

  16.   


            //string utfinfo = txtKeyword.Text;
            //string gb2312info = string.Empty;        //System.Text.Encoding utf8 = System.Text.Encoding.UTF8;
            //System.Text.Encoding gb2312 = System.Text.Encoding.GetEncoding("gb2312");        //// Convert the string into a byte[].
            //byte[] unicodeBytes = utf8.GetBytes(utfinfo);
            //// Perform the conversion from one encoding to the other.
            //byte[] asciiBytes = System.Text.Encoding.Convert(utf8, gb2312, unicodeBytes);        //// Convert the new byte[] into a char[] and then into a string.
            //// This is a slightly different approach to converting to illustrate
            //// the use of GetCharCount/GetChars.
            //char[] asciiChars = new char[gb2312.GetCharCount(asciiBytes, 0, asciiBytes.Length)];
            //gb2312.GetChars(asciiBytes, 0, asciiBytes.Length, asciiChars, 0);
            //gb2312info = new string(asciiChars);
    这是一段 编码转换的代码 你把 Request["name"] 的值 转换一下编码