网上找的,以备后用。

直接上代码:

public static string QueryStringDecode(string key)
        {
            HttpRequest Request = System.Web.HttpContext.Current.Request;

            if (Regex.IsMatch(
                HttpUtility.UrlDecode(Request.Url.Query, Encoding.GetEncoding("iso-8859-1")),
                @"^(?:[\x00-\x7f]|[\xfc-\xff][\x80-\xbf]{5}|[\xf8-\xfb][\x80-\xbf]{4}|[\xf0-\xf7][\x80-\xbf]{3}|[\xe0-\xef][\x80-\xbf]{2}|[\xc0-\xdf][\x80-\xbf])+$"
            ))
            {
                return Request.QueryString[key];
            }
            else
            {
                System.Collections.Specialized.NameValueCollection Rq = HttpUtility.ParseQueryString(Request.Url.Query, System.Text.Encoding.GetEncoding("gb2312"));
                return Rq[key];
            }
        }

 

相关文章:

  • 2021-09-14
  • 2022-12-23
  • 2022-02-08
  • 2022-03-14
  • 2021-06-24
  • 2022-02-08
  • 2022-01-20
  • 2022-02-08
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-19
  • 2022-12-23
  • 2021-07-20
  • 2022-02-08
相关资源
相似解决方案