zoukankan      html  css  js  c++  java
  • Request.Url.Query 和 Request.QueryString的区别

    1、准备   
     string name = "杭州"; 
       string strDefault = HttpUtility.UrlEncode(name,System.Text.Encoding.Default); 
       string strASCII = HttpUtility.UrlEncode(name,System.Text.Encoding.ASCII); 
       string strUnicode = HttpUtility.UrlEncode(name,System.Text.Encoding.Unicode); 
       string strUTF8 = HttpUtility.UrlEncode(name,System.Text.Encoding.UTF8); 
       string strUTF7 = HttpUtility.UrlEncode(name,System.Text.Encoding.UTF7); 
       string name1 = HttpUtility.UrlEncode(name); 

        name1             "%e6%9d%ad%e5%b7%9e"  
     strDefault       "%ba%bc%d6%dd"  
     strASCII          "%3f%3f"  
     strUnicode       "mg%de%5d"  
     strUTF8           "%e6%9d%ad%e5%b7%9e"  
     strUTF7           "%2bZ21d3g-"  

    2、转到另一个的页面测试: 
       Response.Redirect(string.Format("SetJumpIEServerIP.aspx?a1={0}&a2={1}&a3={2}&a4={3}&a5={4}&a6={5}",name1,strDefault,strASCII,strUnicode,strUTF8,strUTF7)); 

    结果 
    (1)、Request.Url.Query 能够显示加密的数据 
     Request.Url.Query "?a1=%e6%9d%ad%e5%b7%9e&a2=%ba%bc%d6%dd&a3=%3f%3f&a4=mg%de%5d&a5=%e6%9d%ad%e5%b7%9e&a6=%2bZ21d3g-" string 

    (2)、Request.QueryString只能显示HttpUtility.UrlEncode(name)的数据 
     Request.QueryString["a1"]  为:  "杭州" string 
     Request.QueryString["a2"]   为:  "" string 
     Request.QueryString["a3"]    为: "??" string 
     Request.QueryString["a4"]  为:"mg]" string 
     Request.QueryString["a5"] 为: "杭州" string 
     Request.QueryString["a6"]  为:"+Z21d3g-" string 


    3、观点:Request.QueryString是很弱的,当非HttpUtility.UrlEncode(name); 
    加密时, 
    就不能正常获得数据。 

  • 相关阅读:
    剑指offer-整数中1出现的次数
    剑指offer-连续子数组的最大和
    剑指offer-最小的k个数
    剑指offer-数组中超过一半的数字
    剑指offer-二叉搜索树与双向链表
    剑指offer-复杂链表的复制
    剑指offer-二叉树中和为某一值的路径
    剑指offer-二叉搜索树的后序遍历
    Alpha 冲刺 (7/10)
    Alpha 冲刺 (6/10)
  • 原文地址:https://www.cnblogs.com/armyfai/p/2779030.html
Copyright © 2011-2022 走看看