惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - 残叶

Enum视为位域 ASP.NET 2.0 HttpHandler实现生成图片验证码(转) Asp.net 2.0生命周期 - 残叶 ASP.NET 2.0 的 App_Offline.htm - 残叶 联合使用抽象类和接口 - 残叶 C#中抽象类和接口的区别 C#静态构造函数 封装K2.net 2003中的K2ROM Asp.net开发小技巧 跨页面提交数据的方法 页面的重定向 - 残叶 (转)关于ASP.net运行流程 O/R Mapping (Object-Relation Mapping,对象关系映射) - 残叶 网络主机名与IP C#发送Email方法总结 @@IDENTITY与SCOPE_IDENTITY() .NET和SQL Server中“空值”辨析 - 残叶 Transactions - 残叶 回家了 - 残叶
(转)Asp.net 中 Get和Post 的用法
残叶 · 2007-06-25 · via 博客园 - 残叶

      表单form的提交有两种方式,一种是get的方法,一种是post 的方法.看下面代码,理解两种提交的区别:

<form id="form1" method="get" runat="server">
    
<div>
        你的名字
<asp:TextBox ID="name" runat="server"></asp:TextBox><br />
        
<br />
        你的网站
<asp:TextBox ID="website" runat="server"></asp:TextBox><br />
        
<br />
        
<br />
        
<asp:Button ID="Button1" runat="server" Text="send" /><br />
        
<br />
        
<br />
        学习request 和 response的用法
<br />
        
<br />
        
<br />
    
</div>
    
</form>

<form id="form2" method="post" runat="server">
    
<div>
        你的名字
<asp:TextBox ID="name2" runat="server"></asp:TextBox><br />
        
<br />
        你的网站
<asp:TextBox ID="website2" runat="server"></asp:TextBox><br />
        
<br />
        
<br />
        
<asp:Button ID="Button2" runat="server" Text="send" /><br />
        
<br />
        
<br />
        学习request 和 response的用法
<br />
        
<br />
        
<br />
    
</div>
    
</form>

从URL中可看出区别.那么那如何编程实现数据的接收呢?

    第1种,接收用get 方法传输的数据的写法:

 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 + "方式传送数据");

    }

第2种,接收用post 方法传输的数据的写法:

 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 + "方式传送数据");

    }

第3种,同时接受get 和post 方法传送数据的代码写法:

A 写法

string id3 = Request.Params["name3"];
        
string website3 = Request.Params["website3"];
        Response.Write(id3 
+ "<br>" + website3);

B 写法

string id4 = Request["name4"];
        
string website4 = Request["website4"];
        Response.Write(id4 
+ "<br>" + website4);

表单提交中get和post方式的区别归纳如下几点:

1. get是从服务器上获取数据,post是向服务器传送数据。
2. get是把参数数据队列加到提交表单的ACTION属性所指的URL中,值和表单内各个字段一一对应,在URL中可以看到。post是通过HTTP post机制,将表单内各个字段与其内容放置在HTML HEADER内一起传送到ACTION属性所指的URL地址。用户看不到这个过程。
3. 对于get方式,服务器端用Request.QueryString获取变量的值,对于post方式,服务器端用Request.Form获取提交的数据。
4. get传送的数据量较小,不能大于2KB。post传送的数据量较大,一般被默认为不受限制。但理论上,IIS4中最大量为80KB,IIS5中为100KB。
5. get安全性非常低,post安全性较高。但是执行效率却比Post方法好。

建议:
1、get方式的安全性较Post方式要差些,包含机密信息的话,建议用Post数据提交方式;
2、在做数据查询时,建议用Get方式;而在做数据添加、修改或删除时,建议用Post方式;

更多区别请看:  http://www.cs.tut.fi/~jkorpela/forms/methods.html#fund