One of the common objects of ASP.NET (REQUEST object)

zhaozj2021-02-16  94

The REQUEST object includes: basic information of the header client (such as the browser type, version number, the language and coding method used by the user) Request method (POST or GET) parameter name parameter value

Request object call method: Request.Collection ["Variable"] where Collection has querystring, form, cookies, servervariables four collection. Collection can be omitted, if you call with Request ["Variable"], but this will reduce efficiency.

Here are these four collection:

QueryString Collection QueryString Collection The information comes from the "?" Number behind the request URL, which is often referred to as "URL additional information": http://www.aspcn.com/show.asp?id=111 here In the URL, the information collected by querystring is "Show.asp?" "ID = 111". At this point, the statement of the parameter value acquired by the parameter ID is: request.queryString ["id"]

The queryString set is primarily used to collect data sent by the GET request in the HTTP protocol. If the "?" Number after the requested program URL is requested, the request is Get. The most common hyperlink is to send a request via the GET. You can also send GET requests via Form, such as:

So, in the show.asp page, you can use the request.queryString ["ID"] to get the parameter value of the ID.

The Form set Form set is similar to queryString, but it is used to collect request data sent by the POST method (the GET method can only pass 256 bytes of data, while POST can reach 2m). The POST request must be sent by form. Such as:

So, in the show.asp page, you can get the parameter value of the ID with the request.form ["ID"].

Cookies collection

ServerVariable Collection ServerVariable Contains system information for servers and clients. --- Client: (1) Get client browser version number: request.serverVariable ["http_user_agent"] (2) Get client IP address: request.serVariable ["remote_addr"] (3) Get the client Language: HTTP_ACCEPT_LANGUAGE (4) Getting the request method: request_method (5) Get the total number of contents of the request information: Content_Length (6) Get the type of request information Content_Type (7) Get additional information of the URL: query_string (8) Get Gateway interface: Gateway_Interface --- Server: (1) Get the IP address of the server: Request.serverVariable ["local_addr"] (2) Get the host name of the server: Request.ServerVariable ["server_name"] (3) Get the current executor Virtual directory: Path_info (4) Get the absolute path of the current executor: Path_Translated (5) Gets the file name of the current program (including virtual path): Script_name (6) Get the port of the server accepts the request: Server_port (7) Get server compliance Protocol and version number: Server_ProtocalBrowser object ASP.NET Browser object is obtained directly by calling Request's Browser property, it can get a more in-depth information to detect browsers in the browser: request.brower.brower display result, for example IE detection browser version: requet.brower.Version display result, such as 6.0b detection browser supports ActiveX control: ActiveXControls Detects the browser support cookies: cookies Detect browser support VBScript: VBScript

Other Request properties, method: * FilePath acquires the file path of the current request, example: string filepath = request.filepath; * httpMethod gets the current request * Files * params get a collection of QueryString Form ServerVariable cookies. * Totalbytes request content size * URL gets URL information, example: httpurl objurl = request.URL; string sport = objurl.Port; string sprotocol = objurl.Protocol; * Userhostaddress (user IP), Userhostname, Userlanguages

转载请注明原文地址:https://www.9cbs.com/read-15294.html

New Post(0)