The object learning of ASP.

Source: Internet
Author: User
Tags html header http post

I. GENERAL statement


second, Detailed introduction

1. Request Object

The Request object is used to obtain all the information that the client provides when requesting a page or transmitting a form , including HTTP variables that can identify the browser and user, cookie information stored on the client, and values appended to the URL (query string or page < form> the value within the HTML control in the segment).

Property


Method

                   

2. Response Object

The response object is used to access the response of the client being created and output information to the client, which provides an HTTP variable that identifies the server and performance, the information sent to the browser, and The information stored in the cookie. It also provides a series of methods for creating output pages, such as ubiquitous response. Write method.

Property

                     

Method


3. Application Object

in an ASP. NET environment, the application object is from the Httpapplictionstat class.

It can share common information between multiple requests, connections, or it can act as a conduit for information passing between individual request connections .

Use the Application object to save the variables we want to pass. Because the Application object is valid throughout the lifetime of the application, it can be accessed on different pages as easily as a global variable.

Property


Method


                   

4. Session Object

The Session object is a number that the server gives to the client .

When a Web server is running, there may be several users browsing the Web site on this server. When each user establishes a connection to this WWW server for the first time, he establishes a session with the server, and the server automatically assigns it a SessionID to identify the user's unique identity.

in particular, the variables of the session object are only valid for a user, and the sessions information of different users is stored with the variables of the different session objects. In the network environment, the variables of the session object have a life cycle, and if the variables of the session object are not refreshed at the specified time, the system terminates the variables.

Property


Method

                   

5. Server Object

The server object provides access to methods and properties on the server. Most of these methods and properties are serviced as functions of the utility. The server object is also a member of the Page object, providing some of the functionality needed to handle page requests , such as building COM objects, compiling code for strings, and so on.

Property


Method

                   


third, the key to grasp

1. Request object interacting with response object

the Request object gets the required parameters first. form form data is submitted to the server in two ways:get and post .


(1) Get is the parameter data queue is added to the submission form the Action property refers to the URL, the value and the form of each field one by one corresponding , in the URL can be seen.

Post is the HTTP post mechanism that places the fields within the form with their contents in the HTML header, along with the URL address referred to by the Action property. the user does not see the process .


(2) for get mode, the server side uses request.querystring[] to get the value of the variable .

for post mode, the server side is used Request.Form. Get () or request[] Gets the submitted data .


(3) The amount of data sent by get is small and cannot be greater than 2KB.

Post transmits a large amount of data , which is generally not restricted by default. In theory, however, the maximum amount of IIS4 is 100KB in 80KB,IIS5.


(4) get security is very low, post security is high .

because the Get method transmits data with some restrictions and is not secure, the form generally does not use the Get method.


After the server is processed, the information is passed back by the response object . There are several ways to do this.


(1 ) Direct output: Response.Write (variable data or string) for example:

Response.Write ("<script Language=javascript>alert (' Welcome to learn ASP] </script>")


(2) link to other Web pages:The redirect method of the Response object redirects the client browser to a different URL, which jumps to another Web page. For example:


(3 ) to terminate the current page run: Response.End ()


(4 ) output The specified file: Response.WriteFile (filename) filename refers to the filename of the file to be output to the browser


2. Lock and unlock in Application object

           There may be situations where multiple users can access the same Application object at the same time. This makes it possible for multiple users to modify the same application named object, resulting in inconsistent data issues.
           The HttpApplicationState class provides two methods of Lock and Unlock to resolve access synchronization issues with application objects, oneonly one thread is allowed to access application state variables at a time。

           About locking and unlocking
           Lock: Application.Lock ()
           Access: Application ("key name") = value
           Unlock: Application.UnLock ()
           Attention:the Lock method and the Unlock method should be used in pairs。

3. Advantages of Session Object


Related reading: ASP. NET built-in objects



The object learning of ASP.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.