zoukankan      html  css  js  c++  java
  • [网络收集]form表单提交方式post和get,Request.QueryString,Request.Form

    //测试页面FormSubmit.aspx:

    //html代码
    </head>
    <body>
         <form id="form1" runat="server" action="FormSubmit.aspx" method="post">
         <div>    
         <input type="text" name="Text" value="Hello World" /><br />
         <input type="text" name="Text" value="Hello World1" /><br />
         <a href="FormSubmit.aspx?Text=Hello World2">a</a>
         <input type="submit" value="提交" />
         </div>
         </form>
    </body>
    </html>

     

    //cs代码
         protected void Page_Load(object sender, EventArgs e)
         {
             if (Request.QueryString["Text"] != "")
             {
                 Response.Write("通过get方法传递来的字符串是: " + Request.QueryString["Text"] + ",<br />通过Request.QueryString

    [\"Text\"]获得");
             }
             if (Request.Form["Text"] != "")
             {
                 Response.Write("<br /><br />通过Post方法传递来的字符串是: " + Request.Form["Text"] + ",<br />通过Request.Form

    [\"Text\"]获得");
             }
             if (Request["Text"] != "")
             {
                 Response.Write("<br /><br />字符串是: " + Request["Text"] + ",<br />通过Request[\"Text\"]获得");
             }

         }

    //运行结果
    通过get方法传递来的字符串是: ,
    通过Request.QueryString["Text"]获得

    通过Post方法传递来的字符串是: Hello World,Hello World1,
    通过Request.Form["Text"]获得

    字符串是: Hello World,Hello World1,
    通过Request["Text"]获得

    //

             //如果IE地址为http://localhost:13409/TempCode/FormSubmit.aspx?Text=Hello+World2,表单提交方式为post方式,测试为post和

    get的混合方式
             //将action=""设置成FormSubmit.aspx?Text=Hello World2或者FormSubmit.aspx,对提交方式不影响
             //<a href="FormSubmit.aspx?Text=Hello World2">a</a>,<!--永远是get提交,不管表单form的method属性设置成post还是get;并

    且以http://localhost:13409/TempCode/FormSubmit.aspx?Text=Hello%20World2传送;取到的值唯一,为Hello World2-->
             //对于按钮,<!--根据表单form的method属性设置成post还是get提交;如果是post,则以

    http://localhost:13409/TempCode/FormSubmit.aspx传送;如果是get方式,则以http://localhost:13409/TempCode/FormSubmit.aspx?

    __VIEWSTATE=%2FwEPDwUJNzgzNDMwNTMzZGTPbywXbcRWoc86gvLdI5ybRPrUbg%3D%3D&Text=Hello+World&Text=Hello+World1方式传送;取到的值不

    唯一,为Hello World,Hello World1-->
             //对于提交之后,获得的值,是将同名的值用逗号隔开的字符串

  • 相关阅读:
    状压dp学习笔记
    dbcc log(转)
    日志分析 操作(转)
    Sql server 2005系统表详细说明
    c#读取并分析sqlServer据库日志(转)
    [POJ]1915 Knight Moves
    [JOY]1143 飘飘乎居士的约会
    [POJ]1164 The Castle
    win7注册ocx时出现对DllRegisterServer的调用失败,错误代码为0x80040200解决方案
    注册DLL、OCX的方法
  • 原文地址:https://www.cnblogs.com/lushuicongsheng/p/1876084.html
Copyright © 2011-2022 走看看