[转载]Request、Request.Form和Request.QueryString的区别
Request、Request.Form和Request.QueryString的区别
request本身是一个系统的静态对象,本身也可以作为数组调用,比如request("abc")就是获取request数组中键值"abc"对应的值,而这个数组又不是固定的,而是多个数组的集合,其中包含了(QueryString ,Form ,Cookies ,ClientCertificate,ServerVariables )这几个服务器变量数组的值,也就是说,通过request可以依次遍历这几个数组并返回对应的值,使用起来很是方便,一劳永逸。
而request.form这个request的成员函数就不是那么宽泛的取值了,仅仅是从form数组中取值,也就是页面表单<form>标签的输入单元(比如<input type=text >传递过来的值。那么通过form就无法获取链接字符串中以index.asp?abc=123这样的形式传递过来的参数了。
还有一种方法是request.QueryString("abc")这种形式,可以获取QueryString 链接字符串传递的参数了。
以http的几种传递数据机制来说,这三种方法可以这样区分。request.form可以获取以post方式提交的数据,requst.querystring可以获取以get方法提交的数据,而request则是可以同时获取两种方法传递的数据。
按照传递数据量来说,request.form可以传递不限大小的数据,而request.querystring只能传递2k的数据量。
按照速度来说,request.qeurystring 会略快于request.form
最方便最好用的嘛,request本身来的直接了,不管怎么传递的数据都能获取,性能嘛,略有下降,可忽略不计,通用的可以使用 request("abc")这样的写法。
Request.Form:获取以POST方式提交的数据(接收Form提交来的数据);
Request.QueryString:获取地址栏参数(以GET方式提交的数据)
Request:包含以上两种方式(优先获取GET方式提交的数据),它会在QueryString、Form、ServerVariable中都搜寻一遍。
而且有时候也会得到不同的结果。如果你仅仅是需要Form中的一个数据,但是你使用了Request而不是Request.Form,那么程序将在QueryString、ServerVariable中也搜寻一遍。如果正好你的QueryString或者ServerVariable里面也有同名的项,你得到的就不是你原本想要的值了。
Request.ServerVariables中的各种参数
Request.ServerVariables("Url")
返回服务器地址
Request.ServerVariables("Path_Info")
客户端提供的路径信息
Request.ServerVariables("Appl_Physical_Path")
与应用程序元数据库路径相应的物理路径
Request.ServerVariables("Path_Translated")
通过由虚拟至物理的映射后得到的路径
Request.ServerVariables("Script_Name")
执行脚本的名称
Request.ServerVariables("Query_String")
查询字符串內容
Request.ServerVariables("Http_Referer")
请求的字符串內容
Request.ServerVariables("Server_Port")
接受请求的服务器端口号
Request.ServerVariables("Remote_Addr")
发出请求的远程主机的IP地址
Request.ServerVariables("Remote_Host")
发出请求的远程主机名称
Request.ServerVariables("Local_Addr")
返回接受请求的服务器地址
Request.ServerVariables("Http_Host")
返回服务器地址
Request.ServerVariables("Server_Name")
服务器的主机名、DNS地址或IP地址
Request.ServerVariables("Request_Method")
提出请求的方法比如GET、HEAD、POST等等
Request.ServerVariables("Server_Port_Secure")
如果接受请求的服务器端口为安全端口时,则为1,否则为0
Request.ServerVariables("Server_Protocol")
服务器使用的协议的名称和版本
Request.ServerVariables("Server_Software")
应答请求并运行网关的服务器软件的名称和版本
Request.ServerVariables("All_Http")
客户端发送的所有HTTP标头,前缀HTTP_
Request.ServerVariables("All_Raw")
客户端发送的所有HTTP标头,其结果和客户端发送时一样,没有前缀HTTP_
Request.ServerVariables("Appl_MD_Path")
应用程序的元数据库路径
Request.ServerVariables("Content_Length")
客户端发出內容的长度
Request.ServerVariables("Https")
如果请求穿过安全通道(SSL),则返回ON如果请求来自非安全通道,则返回OFF
Request.ServerVariables("Instance_ID")
IIS实例的ID号
Request.ServerVariables("Instance_Meta_Path")
响应请求的IIS实例的元数据库路径
Request.ServerVariables("Http_Accept_Encoding")
返回內容如:gzip,deflate
Request.ServerVariables("Http_Accept_Language")
返回內容如:en-us
Request.ServerVariables("Http_Connection")
返回內容:Keep-Alive
Request.ServerVariables("Http_Cookie")
返回內容如:nVisiT%
2DYum=125;ASPSESSIONIDCARTQTRA=FDOBFFABJGOECBBKHKGPFIJI;ASPSESSIONIDCAQQTSRB=LKJJPLABABILLPCOGJGAMKAM;ASPSESSIONIDACRRSSRA=DK
HHHFBBJOJCCONPPHLKGHPB
Request.ServerVariables("Http_User_Agent")
返回內容:Mozilla/4.0(compatible;MSIE6.0;WindowsNT5.1;SV1)
Request.ServerVariables("Https_Keysize")
安全套接字层连接关键字的位数,如128
Request.ServerVariables("Https_Secretkeysize")
服务器验证私人关键字的位数如1024
Request.ServerVariables("Https_Server_Issuer")
服务器证书的发行者字段
Request.ServerVariables("Https_Server_Subject")
服务器证书的主题字段
Request.ServerVariables("Auth_Password")
当使用基本验证模式时,客户在密码对话框中输入的密码
Request.ServerVariables("Auth_Type")
是用户访问受保护的脚本时,服务器用於检验用户的验证方法
Request.ServerVariables("Auth_User")
代证的用户名
Request.ServerVariables("Cert_Cookie")
唯一的客户证书ID号
Request.ServerVariables("Cert_Flag")
客户证书标誌,如有客户端证书,则bit0为0如果客户端证书验证无效,bit1被设置为1
Request.ServerVariables("Cert_Issuer")
用户证书中的发行者字段
Request.ServerVariables("Cert_Keysize")
安全套接字层连接关键字的位数,如128
Request.ServerVariables("Cert_Secretkeysize")
服务器验证私人关键字的位数如1024
Request.ServerVariables("Cert_Serialnumber")
客户证书的序列号字段
Request.ServerVariables("Cert_Server_Issuer")
服务器证书的发行者字段
Request.ServerVariables("Cert_Server_Subject")
服务器证书的主题字段
Request.ServerVariables("Cert_Subject")
客户端证书的主题字段
Request.ServerVariables("Content_Type")
客户发送的form內容或HTTPPUT的数据类型
在.net学习开发中,基础比较重要。现在我将一些最基础的.net知识一点点总结,温故知新。
我们在网页开发的过程中要接受来自页面传来的值,这也是我们要了解的基础内容。
使用Request.Form,ASP是从FORM集合中搜索。
使用Request,ASP是以如下顺序进行搜索:
1.QueryString
2.Form
3.Cookies
4.ClientCertificate
5.ServerVariables
如果在QueryString里也存在一个同Form里相同的变量名,则不会返回Form里的值,而是QueryString的。
Request.form:获取前台form表单以POST方式提交的数据
Request.QueryString :获取地址栏参数(以GET方式提交的数据)
Request:包含以上两种方式(优先获取GET方式提交的数据)
两者除了接收方法不同外,还有传递数据量大小的问题:
Request.form方法能接收的数据没有限制,而Request.QueryString只能接收数据量小于2KB数据,当然后者的执行速度要比前者快。
一般向数据库请求查询时用request.QueryString方法,因为查询时只不过那么几个关键词,没有必要用request.form方法而导致查询速度变慢。
另外,request.QueryString方法还会把数据信息显示在客户端浏览器地址栏中,安全性较差。
request.form方法不存在上述问题,因此大量被应用在多个文本域提交数据和用户登陆的场合。
request对象也可以不指明具体使用QueryString或是form方法,如request("变量"),因为它能自动识别,
不过还是指明为好,否则,要它自己判断也得花些微小的访问时间,影响程序执行效率。
[转载]Request、Request.Form和Request.QueryString的区别的更多相关文章
- 客户端的数据来源:QueryString, Form, Cookie Request[]与Request.Params[]
在ASP.NET编程中,有三个比较常见的来自于客户端的数据来源:QueryString, Form, Cookie . 我们可以在HttpRequest中访问这三大对象. QueryString: 获 ...
- request和request.form和request.querystring的区别
asp中获取传递的参数,一般用request或者用request成员函数request.form,两种方式都可以获取页面表单传递过来的参数值,一直没留意两种方法有什么区别,我一般喜欢用request( ...
- Request.params,Request.form,Request.querystring区别(转)
自己总结:---大致意思是: 1.传参的方式分为:get方式传参,post方式传参,request.cookies和request.servervariables 2.这几种获取参数方式获取的都是一个 ...
- C# Request.Params与Request.QueryString 的区别
1.Request.Params包含Request.QueryString,request.form.request.cookies和request.servervariables.这几种查找的时候会 ...
- 说说Request.Params[key]和Request[key]
摘要 其实你一看到,就应该会想到,这个不简单吗,不就是服务端接收参数的一种方式吗?是的.在asp.net编程中,QueryString.Form.Cookie是三种比较常见的接收客户端参数的方式.Qu ...
- Request的getParameter和getAttribute方法的区别
下面整理一下getParameter和getAttribute的区别和各自的使用范围. (1)HttpServletRequest类有setAttribute()方法,而没有setParam ...
- <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %>
<%String path = request.getContextPath();String basePath = request.getScheme()+"://"+re ...
- 关于String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
关于 String path = request.getContextPath(); String basePath = request.getScheme()+"://"+req ...
- String path = request.getContextPath(); String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";作用!!!!!
<%String path = request.getContextPath();String basePath = request.getScheme()+"://"+re ...
随机推荐
- dos2unix命令
dos2unix命令用来将DOS格式的文本文件转换成UNIX格式的(DOS/MAC to UNIX text file format converter).DOS下的文本文件是以\r\n作为断行标志的 ...
- python的__all__
用来暴露接口 控制 from xxx import * 的行为 代码中当然是不提倡用 from xxx import * 的写法的,但是在 console 调试的时候图个方便还是很常见的.如果一个模块 ...
- [py][mx]django处理登录逻辑
浏览器同源策略(same-origin policy) csrf攻击防御核心点总结 django的cookie和session操作-7天免登录 flask操作cookie&django的see ...
- 异常的Error与Exception
一般不可处理:Error:是jvm抛出的严重性问题.已经严重影响程序执行 例如:内存溢出等情况这种问题发生一般不针对处理,直接修改程序. 可处理:Exception: 该体系的特点:子类的后缀名都是 ...
- list异常
可能定义的时候没有初始化把 private List<Msg> msgList = new ArrayList<>(); 为啥我android老是忘了new ArrayList
- Python_summary
Q: python中出现IndentationError:unindent does not match any outer indentation levelA:复制代码的时候容易出现缩进错误,虽然 ...
- InstallShield 读注册表函数 RegDBGetKeyValueEx ()执行失败
注: rtn = RegDBGetKeyValueEx(szKey, szNumName, nvType, svNumValue, nvSize); 调用失败如果这个函数的几个参数没有初始化的值,调用 ...
- java生成随机六位数的验证码&随机生成十位数ValidCode码,用于邮件的验证&检查是不是符合为合法的中国的手机号码
package com.demo.test1; import java.security.NoSuchAlgorithmException; import java.security.SecureRa ...
- Android -- 打造我们的StepView
1,前两天我们分析了Github开源的StepView <自定义StepView实现个人信息验证进度条>,这两天想着想自己写一个,so,就有了这一篇文章,不废话,先看看实现的效果: 2,首 ...
- TP文件上传
一.单文件上传 <form action="__ACTION__" enctype="multipart/form-data" method=" ...