自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

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

開發(fā) 后端
我們都知道,get是從服務(wù)器上獲取數(shù)據(jù),post是向服務(wù)器上傳數(shù)據(jù)。本文主要介紹ASP.NET中g(shù)et方法和post方法的區(qū)別,一起來看。

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

這里舉個簡單的例子:

(get方法)

html頁面:

  1. <html xmlns="http://www.w3.org/1999/xhtml" > 
  2. <head> 
  3. <title>發(fā)送GET請求</title> 
  4. </head> 
  5. <body> 
  6. <center > 

發(fā)送GET請求

  1. <hr /> 
  2. <form action=default7.aspx method =get > 
  3. 輸入發(fā)送的內(nèi)容:  
  4. <input type =text name="content1" /> 
  5. <br /> 
  6. <input type =submit value ="發(fā)送" /> 
  7. </form> 
  8. </center> 
  9. </body> 
  10. </html> 

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

  1. <html xmlns="http://www.w3.org/1999/xhtml" > 
  2. <head runat="server"> 
  3. <title>接收GET請求</title> 
  4. </head> 
  5. <body> 
  6. <center > 

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

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

(post方法)

html頁面:

  1. <html xmlns="http://www.w3.org/1999/xhtml" > 
  2. <head> 
  3. <title>發(fā)送post請求</title> 
  4. </head> 
  5. <body> 
  6. <center > 

發(fā)送post請求

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

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

  1. <input type =text name="content1" /> 
  2. <br /> 
  3. <input type =submit value ="發(fā)送" /> 
  4. </form> 
  5. </center> 
  6. </body> 
  7. </html> 

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

  1. <html xmlns="http://www.w3.org/1999/xhtml" > 
  2. <head runat="server"> 
  3. <title>接收post請求</title> 
  4. </head> 
  5. <body> 
  6. <center > 

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

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

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

【編輯推薦】

  1. ASP.NET配置文件Web.config詳細解釋
  2. ASP.Net中保護自定義的服務(wù)器控件
  3. 一款經(jīng)典的ajax登錄頁面 后臺asp.net
  4. 使用ASP.NET操作IIS7中使用應(yīng)用程序
  5. 淺述asp.net海量分頁數(shù)據(jù)存儲過程

 

責(zé)任編輯:于鐵 來源: 互聯(lián)網(wǎng)
相關(guān)推薦

2009-07-29 16:53:52

ASP.NET Get

2011-06-08 11:36:16

ASP.NETrender

2009-07-28 13:26:34

Render方法ASP.NET

2009-07-22 18:03:00

ASP.NET ASP

2009-07-27 12:22:03

ASP.NET和ASPASP.NET入門教程

2009-08-03 14:39:25

Asp.Net函數(shù)集

2009-01-04 13:27:10

URL RewriteIISASP.NET

2009-07-27 09:29:38

ASP.NET中Jav

2009-07-30 13:33:55

ASP.NET中的co

2009-07-20 16:04:37

ASP.NET fra

2009-07-22 09:11:02

Action方法ASP.NET MVC

2009-08-21 18:00:38

ASP.NET mac

2009-07-23 14:47:03

Page_Load方法ASP.NET

2009-05-31 08:54:22

WEB開發(fā)ASP.NETApplication

2011-06-08 10:28:15

ASP.Net

2009-07-23 15:11:43

XML Web服務(wù)方法ASP.NET

2009-08-05 14:27:55

ASP.NET模板基本

2009-07-21 09:43:36

調(diào)用UpdatePanASP.NET

2009-08-04 17:28:45

Apache支持ASP

2009-06-26 16:23:12

Hibernate gHibernate l
點贊
收藏

51CTO技術(shù)棧公眾號