zoukankan      html  css  js  c++  java
  • form里面的action和method(post和get的方法)使用

    一、form里面的action和method的post使用方法

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="formsubmitpost.aspx.cs" Inherits="formsubmitpost" %>
    
    <!DOCTYPE html>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server" action="formsubmitget.aspx" method="post">
        <div>
        <input id="b" name="b" value="123" />
            <input  id="w" type="submit" />
        </div>
        </form>
    </body>
    </html>

    当你点击button按钮提交的时候,浏览器的地址为http://localhost:1621/formsubmitpost.aspx,页面会刷新但是地址不变

    二、form里面的action和method的get使用方法

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="formsubmitget.aspx.cs" Inherits="formsubmitget" %>
    
    <!DOCTYPE html>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server" action="formsubmitget.aspx" method="get">
        <div>
        <input id="a" name="a" value="123" />
            <input  id="w" type="submit" />
        </div>
        </form>
    </body>
    </html>

    但你点击button提交的时候,浏览器地址为http://localhost:1621/formsubmitget.aspx?__VIEWSTATE=%2FwEPDwUKLTEzNDM3NzkxOWRkeBFIL8xbs6u8bVKlOO5sf6FSAk0OTJ6ZUC4n2AN9oe4%3D&a=123&__VIEWSTATEGENERATOR=4B2C1984

    而这个地址包含你传过去的值。

    综上,

    get:

    1>通过GET提交数据,用户名和密码将明文出现在URL上,因为登录页面有可能被浏览器缓存,GET请求请提交的数据放置在HTTP请求协议头

    2>或者其他人查看浏览器的历史纪录,那么别人就可以拿到你的账号和密码了,除此之外,使用GET提交数据还可能会造成Cross-site request forgery攻击,所以不安全

    3> GET请求有长度限制

    post:

    1>POST数据放在body(POST提交的数据则放在实体数据),POST请求数据不能被缓存下来

    2> POST请求参数不会被保存在浏览器历史或 web 服务器日志中。

    3> POST请求没有长度限制

  • 相关阅读:
    oracle 导入数据时提示只有 DBA 才能导入由其他 DBA 导出的文件
    oracle 常用语句
    android udp 无法收到数据 (模拟器中)
    android DatagramSocket send 发送数据出错
    AtCoder ABC 128E Roadwork
    AtCoder ABC 128D equeue
    AtCoder ABC 127F Absolute Minima
    AtCoder ABC 127E Cell Distance
    CodeForces 1166E The LCMs Must be Large
    CodeForces 1166D Cute Sequences
  • 原文地址:https://www.cnblogs.com/May-day/p/5515780.html
Copyright © 2011-2022 走看看