Home > Article > Backend Development > Share five methods of obtaining client data using the request object in ASP.
Asp's built-in request object has five methods for obtaining client data (QueryString/Form/Cookies/ServerVariables/ClientCertificate).
Syntax: request.Method name("parameter")|request("parameter")
If the latter is used, the system will automatically select the corresponding method.
1. Form
Here we re-emphasize some properties of Form:
Enctype=资料传送的MIME形态 Method=传送资料的方式Get/Post Onrest=按下rest键调用的程序 Onsubmit=按下sumit键调用程序 Target=输出内容的frame窗口>
There are generally three ways to use Form to transmit information: from the Form in the html web page to transmit information to other Asp; the Form in Asp transmits information to another Asp; the information in Asp is transmitted to itself.
Syntax: Request.Form(parameter)[(index)]
The parameter represents the name of the element in the Form, and the index represents the sequence number of the element with the same name.
Example:
The element named user can be read in a loop, where Count is the system property of Form, which is used to count the number of elements with the same name. If the element does not exist, its value is zero. If it is not specified which element with the same name is to be read, the system will read the values of all elements with the same name and use "," as a separation.
Example:
Request.form("user")=abc,bcd,cde
2. QueryString
Syntax: Request.QueryString(parameter)[(index)]
In addition to using Form to transmit data, Information can also be transmitted by following the hyperlink with "?", such as:, then the transmitted information can be read through Request.QueryString("user"); if there are multiple parameters with the same name, such as:, then First time
Resquest.QueryString("user")=abc,第二次 Resquest.QueryString("user")=bcd,第三次 Resquest.QueryString("user")=cde。
3. ServerVariables
Syntax: ServerVariables (parameter name)
We know that the transmission protocol of Web/Browse is http, and the header of http will There is some client information, such as
client IP address, browser language system, etc. At this time, you can obtain relevant information through Request.ServerVariables("***"). For example, Request.ServerVariables("Accept_Language") can obtain the language system of the client browser. See the table below for other system parameters:
SERVER_NAME server的机器名称或IP地址。 SERVER_PORT server正在运行的端口号 REQUEST_METHOD 发出request的方法(GET/POST/HEAD SCRIPT_NAME 程序被调用的路径,如:CGI-bin/a.pl。 REMOTE_HOST 发出request请求的远端机器(client)的名称。 REMOTE_ADDR 发出request请求的远端机器(client)的IP地址。 REMOTE_IDENT 发出request的使用者名称(如是拨号上网,则为用户ID),当NCSA IdentityCheck为enabled,而且client机器支持RFC 931时,该变量有效。 CONTENT_TYPE 数据的MIME类型,如:“text/html”。 HTTP_ACCEPT client可以接受的MIME类型列表。 HTTP_USER_AGENT client发出request的浏览器类型。 HTTP_REFERER 在读取CGI程序之前,client所指的文本URL。
4. Cookies
On the client side, Cookies record a lot of information about the client browser. We can use the Request.Cookies ("name") command Get its value, or record some information on the client through Response.Cookies("name")="value" to control visitors. The method to set multiple cookies is Response.Cookies("name")("name")="value".
5. Cache
We can set up the browser to extract information about the pages that have been visited from the Cache. Similarly, similar settings can be made in the Asp program. Among them, Response.Clear clears the client's memory. Response.Buffer=True setting can read data from Cache (default is False).
6. ClientCertificate
ClientCertificate is used to obtain the identity confirmation information of the client browser (in compliance with the X.509 standard), but the client browser must support the SSL3.0 or PCT1 protocol. Two steps are required here. The first step: the web server must enable the client authentication option; the second step: set the client browser accordingly so that this method will take effect. Otherwise, the empty value will be returned.
【Related Recommendations】
1. Summary of Asp.net built-in object Request object usage examples
2. Share a small case of Request object
3. Talk about the use of Request and Response objects
4. Detailed explanation of ASP.NET system object Request
The above is the detailed content of Share five methods of obtaining client data using the request object in ASP.. For more information, please follow other related articles on the PHP Chinese website!