最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

ASP.NET Get和Post兩種提交方法淺析

 更新時(shí)間:2013年03月17日 11:56:56   作者:  
表單form的提交有兩種方式,一種是get的方法,一種是post 的方法.看下面代碼,理解ASP.NET Get和Post兩種提交的區(qū)別:

復(fù)制代碼 代碼如下:

< form id="form1" method="get" runat="server">

       < div>  姓名字< asp:TextBox ID="name" runat="server">< /asp:TextBox>< br /> 

                  你的網(wǎng)站< asp:TextBox ID="website" runat="server">< /asp:TextBox>< br />

                   < asp:Button ID="Button1" runat="server" Text="send" />< br />

                  學(xué)習(xí)request 和 response的用法< br />

   < /div>

 </form>

 < form id="form2" method="post" runat="server">

       < div>  姓名字< asp:TextBox ID="name2" runat="server">< /asp:TextBox>< br /> 

                  你的網(wǎng)站< asp:TextBox ID="website2" runat="server">< /asp:TextBox>< br />

                   < asp:Button ID="Button2" runat="server" Text="send" />< br />

                  學(xué)習(xí)request 和 response的用法< br />

     < br />

 </form>

從URL中可看出ASP.NET Get和Post的區(qū)別.那么那如何編程實(shí)現(xiàn)數(shù)據(jù)的接收呢?

  第1種,接收用get 方法傳輸?shù)臄?shù)據(jù)的寫(xiě)法:

復(fù)制代碼 代碼如下:

 protected void Page_Load(object sender, EventArgs e)

       {

           string id = Request.QueryString["name"];

           string website = Request.QueryString["website"];

           Response.Write(id + "< br>" + website);

          Response.Write("你使用的是" + Request.RequestType + "方式傳送數(shù)據(jù)");

       }

第2種,接收用post 方法傳輸?shù)臄?shù)據(jù)的寫(xiě)法:

復(fù)制代碼 代碼如下:

protected void Page_Load(object sender, EventArgs e)

       {

           string id2 = Request.Form["name2"];

           string website2 = Request.Form["website2"];

           Response.Write(id2 + "< br>" + website2);

           Response.Write("你使用的是" + Request.RequestType + "方式傳送數(shù)據(jù)");

     }

第3種,同時(shí)接受get和post 方法傳送數(shù)據(jù)的代碼寫(xiě)法:  A 寫(xiě)法

復(fù)制代碼 代碼如下:

  string id3 = Request.Params["name3"];

  string website3 = Request.Params["website3"];

  Response.Write(id3 + "< br>" + website3);

B 寫(xiě)法

復(fù)制代碼 代碼如下:

   string id3 = Request.Params["name3"];

   string website3 = Request.Params["website3"];

   Response.Write(id3 + "< br>" + website3);


B 寫(xiě)法
復(fù)制代碼 代碼如下:

   string id4 = Request["name4"];

   string website4 = Request["website4"];

   Response.Write(id4 + "< br>" + website4);


表單提交中,ASP.NET的Get和Post方式的區(qū)別歸納如下幾點(diǎn):

• get是從服務(wù)器上獲取數(shù)據(jù),post是向服務(wù)器傳送數(shù)據(jù)。

 get是把參數(shù)數(shù)據(jù)隊(duì)列加到提交表單的ACTION屬性所指的URL中,值和表單內(nèi)各個(gè)字段一一對(duì)應(yīng),在URL中可以看到。post是通過(guò)HTTP post機(jī)制,將表單內(nèi)各個(gè)字段與其內(nèi)容放置在HTML HEADER內(nèi)一起傳送到ACTION屬性所指的URL地址。用戶(hù)看不到這個(gè)過(guò)程。

 對(duì)于get方式,服務(wù)器端用Request.QueryString獲取變量的值,對(duì)于post方式,服務(wù)器端用Request.Form獲取提交的數(shù)據(jù)。

 get傳送的數(shù)據(jù)量較小,不能大于2KB。post傳送的數(shù)據(jù)量較大,一般被默認(rèn)為不受限制。

 get安全性非常低,post安全性較高。但是執(zhí)行效率卻比Post方法好

               建議:

 get方式的安全性較Post方式要差些,包含機(jī)密信息的話(huà),建議用Post數(shù)據(jù)提交方式;

  在做數(shù)據(jù)查詢(xún)時(shí),建議用Get方式;而在做數(shù)據(jù)添加、修改或刪除時(shí),建議用Post方式

每天早上敲醒自己的不是鬧鐘,是夢(mèng)想!

相關(guān)文章

最新評(píng)論

曲周县| 哈密市| 额尔古纳市| 镇原县| 湛江市| 天祝| 图片| 永康市| 平顶山市| 班玛县| 闸北区| 汝城县| 小金县| 隆德县| 拜城县| 大荔县| 四川省| 四会市| 麻栗坡县| 洛浦县| 得荣县| 波密县| 大新县| 泰和县| 和林格尔县| 霸州市| 巧家县| 安远县| 永州市| 丹东市| 丽江市| 始兴县| 东辽县| 南郑县| 镇平县| 鄂伦春自治旗| 宁国市| 富平县| 沛县| 白水县| 东乌珠穆沁旗|