欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

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

 更新時(shí)間:2015年10月19日 11:33:04   投稿:lijiao  
我們都知道,get是從服務(wù)器上獲取數(shù)據(jù),post是向服務(wù)器上傳數(shù)據(jù)。本文主要介紹ASP.NET中g(shù)et方法和post方法的區(qū)別,需要的朋友可以參考下

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

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

get方法

html頁(yè)面:

<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頁(yè)面:

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

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

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

post方法

html頁(yè)面:

<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頁(yè)面:

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

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

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

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

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

相關(guān)文章

最新評(píng)論