ASP.NET form method "post" and "get"
https://forums.asp.net/t/1796310.aspx?ASP+NET+form+method+post+and+get+
GET:
1) Data is appended to the URL(QueryString)
2) Data is not secret.(Can be seen by anyone)
3) It is a single call system
4) Maximum data that can be sent is 256.
5) Data transmission is faster
6) This is the default method for many browsers
POST:
1) Data is not appended to the URL but sent as part of Http Body.
2) Data is Secret
3) It is a two call system.
4) There is no Limit on the amount of data.That is characters any amount of data can be sent.
5) Data transmission is comparatively slow.
6) No default and should be Explicitly specified.
https://social.technet.microsoft.com/wiki/contents/articles/11697.using-method-type-postget-in-asp-net-web-form.aspx
I will start the article from with detailed information.
Actually form has two types of in asp.net2.0.
1) Get
2) Post
When working with Get method:
- We can access all form input variables in the next page which we mentioned in the action attribute.
- All the submitted information is displayed in the address bar as part of the URL.
- Url Which is not secured because values will be shown in address bar
When working with Post method:
- we can access the variables in the page which we mentioned in the action attribute.
- we can access those variable as shown below
- which is more secured, variable not accessible
Now we will have small application with 2 web pages
1) default.aspx
2) Webform.aspx
GET:
- I have given the value for action attribute is webform1.aspx in the default.aspx page with method type
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form action="webform1.aspx" method="get" >
First name: <input type="text" name="fname" /><br />
Last name: <input type="text" name="lname" /><br />
Age: <input type="text" name="age" /><br />
<input type="submit" value="Submit" />
</form>
</body>
</html>
- Variables will be available in the address bar like below .
http://localhost:50920/webform1.aspx?fname=jhon&lname=smith&age=30 
- We can access the variables from the Address to Form using Request.QueryString[] like below.
protected void Page_Load(object sender, EventArgs e)
{
if (Request.QueryString["fname"] != null)
{
Response.Write("fname : " + Request.QueryString["fname"] + \n");
}
if (Request.QueryString["lname"] != null)
{
Response.Write("lname : " + Request.QueryString["lname"] + "");
}
}
POST:
- Variables will be post to the next page using Post method type
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form action="webform1.aspx" method="post" >
First name: <input type="text" name="fname" /><br />
Last name: <input type="text" name="lname" /><br />
Age: <input type="text" name="age" /><br />
<input type="submit" value="Submit" />
</form>
</body>
</html>
- We cannot access the variables from the url.
http://localhost:50920/webform1.aspx 
- We can access the variables from the request. Form [].
protected void Page_Load(object sender, EventArgs e)
{
if (Request.Form["fname"] != null)
{
Response.Write("fname : " + Request.Form["fname"] + "\n");
}
if (Request.Form["lname"] != null)
{
Response.Write("lname : " + Request.Form["lname"] + "");
}
}
https://www.w3schools.com/tags/ref_httpmethods.asp
The GET Method
Note that the query string (name/value pairs) is sent in the URL of a GET request:
Some other notes on GET requests:
- GET requests can be cached
- GET requests remain in the browser history
- GET requests can be bookmarked
- GET requests should never be used when dealing with sensitive data
- GET requests have length restrictions
- GET requests should be used only to retrieve data
The POST Method
Note that the query string (name/value pairs) is sent in the HTTP message body of a POST request:
Host: w3schools.com
name1=value1&name2=value2
Some other notes on POST requests:
- POST requests are never cached
- POST requests do not remain in the browser history
- POST requests cannot be bookmarked
- POST requests have no restrictions on data length
https://security.stackexchange.com/questions/33837/get-vs-post-which-is-more-secure
POST is more secure than GET for a couple of reasons.
GET parameters are passed via URL. This means that parameters are stored in server logs, and browser history. When using GET, it makes it very easy to alter the data being submitted the the server as well, as it is right there in the address bar to play with.
The problem when comparing security between the two is that POST may deter the casual user, but will do nothing to stop someone with malicious intent. It is very easy to fake POST requests, and shouldn't be trusted outright.
The biggest security issue with GET is not malicious intent of the end-user, but by a third party sending a link to the end-user. I cannot email you a link that will force a POST request, but I most certainly can send you a link with a malicious GET request. I.E:
Click Here for the best free movies!
Edit:
I just wanted to mention that you should probably use POST for most of your data. You would only want to use GET for parameters that should be shared with others, i.e: /viewprofile.php?id=1234, /googlemaps.php?lat=xxxxxxx&lon=xxxxxxx
ASP.NET form method "post" and "get"的更多相关文章
- html form method 属性不支持put,delete请求方式,以及开启spring mvc的rest的方式
1.加上隐藏域解决form method 不支持put,delete的请求方式的问题 2.配置spring mvc HiddenHttpMethodFilter过滤器实现对put和delete请求方式 ...
- asp.net form身份认证不定时认证失败的问题 排查
1.网站出现form认证不定时认证失败.登陆过后 每隔一会儿就需要重新登陆.首先检查的是form身份认证票据设置的时间(正常) 然后检查加密后的身份认证信息写入的cookie的失效时间(正常) 2.这 ...
- Asp.Net Form验证不通过,重复登录
问题产生根源: 当然,其实应该需要保持线上所有机器环境一致!可是,写了一个小程序.使用的是4.5,aysnc/await实在太好用了,真心不想把代码修改回去. so,动了念头,在这台服务器上装个4.5 ...
- Asp.net Form登陆认证的回顾学习
asp.net网站中,我最常用的就是Form认证了,在实现登陆时,利用Form认证实现用户的访问权限,哪些页面是可以匿名登陆,哪些页面需要认证后才能访问,哪些页面不能访问等等权限.我还可在登陆时,使用 ...
- asp.net Form 认证【转】
第一部分 如何运用 Form 表单认证 一. 新建一个测试项目 为了更好说明,有必要新建一个测试项目(暂且为“FormTest”吧),包含三张页面足矣(Default.aspx.Logi ...
- Asp.Net Form表单控件的回车默认事件
当form表单文本框控件在收到回车事件时,默认会触发表单内第一个可提交按钮的事件,但业务中可能要求有其它控件进行提交,而不是这个默认的 这时需要脚本控件事件冒泡传递取消回事事件. $(document ...
- Asp.Net Form验证不通过,重复登录(.net4,4.5form验证兼容性问题)
问题产生根源: 当然,其实应该需要保持线上所有机器环境一致!可是,写了一个小程序.使用的是4.5,aysnc/await实在太好用了,真心不想把代码修改回去. so,动了念头,在这台服务器上装个4.5 ...
- asp.net form 验证方式的使用(转载)
如何运用 Form 表单认证 ASP.NET 的安全认证,共有“Windows”“Form”“Passport”“None”四种验证模式.“Windows”与“None”没有起到保护的作用,不推荐使用 ...
- form&method【POST~GET】
<form.../>中method属性指定了该表单是以哪种方式提交请求,有两种方式:GET请求方式和POST请求方式,默认是GET请求方式.两种方式的区别:get方式的请求是在浏览器地址栏 ...
随机推荐
- IT关键词,面试知识问与答
二叉树遍历的三种方式? 遍历是指依次访问⼆叉树中的每个元素.有三种遍历⽅法,分别是前序遍历. 中序遍历和后序遍历.它们是按照访问根节点和⼦节点的先后顺序命名的. • 前序遍历:先访问根节点,然后访问左 ...
- dnscat使用——整体感觉这个工具不完善,失败率很高,传文件时候没有完整性校验,我自己测试时通过域名转发失败,可能是其特征过于明显导致
git clone https://github.com/iagox86/nbtool make 然后就可以按照下面的官方说明进行操作了. 我的感受:整体感觉这个工具不完善,失败率很高,传文件时候没有 ...
- 利用flashback transaction query新特性进行事务撤销
具备了flashback version query查询的基础,我们就可以进行基于flashback version query的恢复.这就是flashback transaction query.f ...
- 阿里云主机ssh 免密码登录
云主机配置: 操作系统: CentOS 7.0 64位CPU: 1 核公网IP: 78.129.23.45用户名: root密码:bugaosuni 本地环境:我在VMware下安装的Ubuntu 1 ...
- Android 多个APK共享数据
Android给每个APK进程分配一个单独的用户空间,其manifest中的userid就是对应一个Linux用户(Android 系统是基于Linux)的.所以不同APK(用户)间互相访问数据默认是 ...
- Struts2简单环境搭建
一.开篇 Struts2是一个运行于web容器的表示层框架,其核心作用是帮助我们处理Http请求.Struts2处理Http请求(Request),并进行内部处理,再进行Http返回. 下载strut ...
- 函数与装饰器Python学习(三)
1.1 文件处理 1.1.1 打开文件过程 在Python中,打开文件,得到文件句柄并赋值给一个变量,默认打开模式就为r f=open(r'a.txt','w',encoding='utf-8') p ...
- Custom Hosting in IIS/WAS
常常需要与宿主实例进行交互.这对于使用自托管的方式是不可或缺的.当使用IIS或WAS时,不能直接访问宿主.为了克服这个障碍,WCF提供了一个宿主工厂.在.svc文件中使用Factory标签,使用此工厂 ...
- 其他信息: 具有固定名称“Npgsql”的 ADO.NET 提供程序未在计算机或应用程序配置文件中注册或无法加载。有关详细信息,请参阅内部异常
其他信息: 具有固定名称“Npgsql”的 ADO.NET 提供程序未在计算机或应用程序配置文件中注册或无法加载.有关详细信息,请参阅内部异常 解决方法 在 App.config 的 configur ...
- 路飞学城Python-Day31
19-生产者消费者模型 生产者:生成数据的任务 消费者:处理数据的任务 在并发编程的过程中,如果生产者处理速度很快,而消费者处理速度很慢,那么生产者就必须等待消费者处理,才能继续生产数据:同样的,如果 ...