国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

區(qū)分ASP.NET中g(shù)et方法和post方法

2024-07-10 12:47:41
字體:
供稿:網(wǎng)友

在網(wǎng)頁設(shè)計(jì)中,無論是動(dòng)態(tài)還是靜態(tài),get方法是默認(rèn)的,它在URL地址長度是有限的,所以get請(qǐng)求方法能傳送的數(shù)據(jù)也是有限的,一般get方法能傳遞256字節(jié)的數(shù)據(jù),當(dāng)get請(qǐng)求方法傳遞的數(shù)據(jù)長度不能滿足需求時(shí),就需要采用另一種請(qǐng)求方法post,post方法可傳遞的數(shù)據(jù)最大值為2mb相應(yīng)地,讀取post方法傳遞過來的數(shù)據(jù)時(shí),需要采用form方法來獲取;post方法在aspx頁面執(zhí)行時(shí),地址欄看不到傳送過來的參數(shù)數(shù)據(jù),更加有利于頁面的安全,所以一般情況采用post方法傳送頁面數(shù)據(jù)。

這里舉個(gè)簡單的例子:

get方法

html頁面:

<html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>發(fā)送GET請(qǐng)求</title> </head> <body> <center > 

發(fā)送GET請(qǐng)求

<hr /> <form action=default7.aspx method =get > 輸入發(fā)送的內(nèi)容: <input type =text name="content1" /> <br /> <input type =submit value ="發(fā)送" /> </form> </center> </body> </html> 

對(duì)應(yīng)的aspx頁面:

<html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>接收GET請(qǐng)求</title> </head> <body> <center > 

接收GET方法傳來的內(nèi)容:

<hr /> <% string content = Request.QueryString["content1"]; Response.Write("GET方法發(fā)送過來的內(nèi)容為:"+content); %> </center> </body> </html> 

post方法

html頁面:

<html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>發(fā)送post請(qǐng)求</title> </head> <body> <center > 

發(fā)送post請(qǐng)求

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

輸入發(fā)送的內(nèi)容:

<input type =text name="content1" /> <br /> <input type =submit value ="發(fā)送" /> </form> </center> </body> </html> 

對(duì)應(yīng)的aspx頁面:

<html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>接收post請(qǐng)求</title> </head> <body> <center > 

接收post方法傳來的內(nèi)容:

<hr /> <% string content=Request .Form ["content1"]; Response.Write("POST方法發(fā)送過來的內(nèi)容為:"+content); %> </center>  </body> </html> 

用get方法,當(dāng)執(zhí)行aspx頁面時(shí),地址欄的顯示有一段字符“?content1=html輸入的值”,而用post方法,沒顯示,相比之下,post方法比較安全適用。

以上就是本文的全部內(nèi)容,大家應(yīng)該對(duì)get方法和post方法存在的區(qū)別有所了解了吧,希望本文對(duì)大家的學(xué)習(xí)有所幫助。

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 浮梁县| 定西市| 洮南市| 布拖县| 伊川县| 政和县| 清河县| 巴南区| 博湖县| 大邑县| 时尚| 诸城市| 太康县| 昌江| 达州市| 色达县| 武陟县| 邯郸市| 武胜县| 萝北县| 盐亭县| 交口县| 遂平县| 云龙县| 南宫市| 普洱| 东阳市| 龙川县| 衡阳县| 平原县| 江西省| 迁西县| 垫江县| 诸城市| 桓仁| 郁南县| 页游| 盱眙县| 拜泉县| 长汀县| 仲巴县|