• 企业400电话
  • 微网小程序
  • AI电话机器人
  • 电商代运营
  • 全 部 栏 目

    企业400电话 网络优化推广 AI电话机器人 呼叫中心 网站建设 商标✡知产 微网小程序 电商运营 彩铃•短信 增值拓展业务
    区分ASP.NET中get方法和post方法

    在网页设计中,无论是动态还是静态,get方法是默认的,它在URL地址长度是有限的,所以get请求方法能传送的数据也是有限的,一般get方法能传递256字节的数据,当get请求方法传递的数据长度不能满足需求时,就需要采用另一种请求方法post,post方法可传递的数据最大值为2mb相应地,读取post方法传递过来的数据时,需要采用form方法来获取;post方法在aspx页面执行时,地址栏看不到传送过来的参数数据,更加有利于页面的安全,所以一般情况采用post方法传送页面数据。

    这里举个简单的例子:

    get方法

    html页面:

    html xmlns="http://www.w3.org/1999/xhtml" > 
    head> 
    title>发送GET请求/title> 
    /head> 
    body> 
    center > 

    发送GET请求

    hr /> 
    form action=default7.aspx method =get > 
    输入发送的内容: 
    input type =text name="content1" /> 
    br /> 
    input type =submit value ="发送" /> 
    /form> 
    /center> 
    /body> 
    /html> 
    

    对应的aspx页面:

    html xmlns="http://www.w3.org/1999/xhtml" > 
    head runat="server"> 
    title>接收GET请求/title> 
    /head> 
    body> 
    center > 
    

    接收GET方法传来的内容:

    hr /> 
    % 
    string content = Request.QueryString["content1"]; 
    Response.Write("GET方法发送过来的内容为:"+content); 
    %> 
    /center> 
    /body> 
    /html> 
    

    post方法

    html页面:

    html xmlns="http://www.w3.org/1999/xhtml" > 
    head> 
    title>发送post请求/title> 
    /head> 
    body> 
    center > 
    

    发送post请求

    hr /> 
    form action =default8.aspx method =post > 
    

    输入发送的内容:

    input type =text name="content1" /> 
    br /> 
    input type =submit value ="发送" /> 
    /form> 
    /center> 
    /body> 
    /html> 
    

    对应的aspx页面:

    html xmlns="http://www.w3.org/1999/xhtml" > 
    head runat="server"> 
    title>接收post请求/title> 
    /head> 
    body> 
    center > 
    

    接收post方法传来的内容:

    hr /> 
    % 
    string content=Request .Form ["content1"]; 
    Response.Write("POST方法发送过来的内容为:"+content); 
    %> 
    /center>  
    /body> 
    /html> 
    

    用get方法,当执行aspx页面时,地址栏的显示有一段字符“?content1=html输入的值”,而用post方法,没显示,相比之下,post方法比较安全适用。

    以上就是本文的全部内容,大家应该对get方法和post方法存在的区别有所了解了吧,希望本文对大家的学习有所帮助。

    您可能感兴趣的文章:
    • Asp.net XMLHTTP封装类(GET,Post发送和接收数据)
    • ASP.NET的HtmlForm控件学习及Post与Get的区别概述
    • ASP.NET Get和Post两种提交方法浅析
    • asp.net页面与页面之间传参数值方法(post传值和get传值)
    上一篇:ASP.NET比较常用的26个性能优化技巧
    下一篇:SQL Server数据库连接 Web.config如何配置
  • 相关文章
  • 

    © 2016-2020 巨人网络通讯

    时间:9:00-21:00 (节假日不休)

    地址:江苏信息产业基地11号楼四层

    《增值电信业务经营许可证》 苏B2-20120278

    区分ASP.NET中get方法和post方法 区分,ASP.NET,中,get,方法,