ASP Getting Started tutorials-response Common properties for objects

Source: Internet
Author: User
Tags flush client

First, buffer properties

The Response object's Buffer property is used to determine whether to output a buffered page, which is to control when the output information is sent to the requesting browser. The value of the buffer can be "true" or "False", if the buffer page is used, if the Web server output uses a buffer page, the data is transferred to the client only if all server scripts for the current page have been processed or the flush or End method is invoked, if False Indicates that the buffer page is not used, and the data is routed to the client while all server script processing for the current page is processed. The syntax format is as follows:

Responser.Ruffer= True | False

Note: in the. asp page, the statement that sets the buffer property should be placed on the first line following the <% @ Language%> command. If the current ASP script buffer is set to True but the Flush method is not invoked, the server keeps the client's request active and saves time by not having to create a new connection for each client. If you change the value of the Buffer property after the HTML or script output, an error occurs. Actually example four and instance five in the previous section.

Second, Expire properties

The Expires property of the response object is used to determine how much time (in units) the buffer storage page will expire on the browser. If a user returns to the page before the page expires, the page in the buffer is displayed, otherwise the page is re-read from the server. The syntax format is as follows:

Response.Expires [=number]

Annotations:

Setting this property to 0 allows the cached page to expire immediately. If this property is set more than once on a page, the shortest time is used. This property is more practical. For example, when a customer enters a Web site through an ASP's login page, this property should be used to expire the landing page immediately (set response.expires=0). To ensure safety.

Instance one: The following two pages (4-2f.asp and 4-2f1.asp) call the Expires property, and the expires value is set to 1 in the 4-2f.asp page. This means that the cached page on the browser can be kept for 1 minutes, when we enter the URL of this page in the Address bar and press ENTER (do not press the F5 key or click the "Refresh" button), you will see that the displayed time remains the same, 1 minutes after the cached page expires, the time shown is beginning to change. In the 4-2f1.asp page, set the value of expires to 0, and whenever you enter the URL address of the file in the address bar, you will see that the time displayed is changing. The code is as follows:

The 4-2f.asp page code is as follows:

<% @ language="vbscript" %>
<% Response.Buffer=true %>
<% Response.Expires=1 %> '将Expires的属性设置为1。
<body>
<center>
<font face="华文彩云" size="7" color="red"><b>现在是:<% =time() %></b></font>
</center>
</body>

The 4-2f1.asp page code is as follows:

<% @ language="vbscript" %>
<% Response.Buffer=true %>
<% Response.Expires=0 %> '将Expires的属性设置为0。
<body>
<center>
<font face="华文彩云" size="7" color="red"><b>现在是:<% =time() %></b></font>
</center>
</body>

Note: Please copy and paste the code of the above two examples into your own corresponding software to build the Web page and put it on your computer's home directory for testing.

Three, Response Expireabsolute attribute

The ExpiresAbsolute property of the Responser object specifies the exact expiration date and time of the page that is cached in the browser (the Expires property specifies the relative expiration time). If the user returns to the page before it expires, the page in the cache is displayed. If no time is specified, the home page expires at midnight on the same day. If no date is specified, the home page expires when the script is run to the specified time of the day. The syntax format is as follows:

Response.ExpiresAbsolute [= [date] [time]]

Example two: The following statement specifies that the page expires in 15 seconds at 8 o'clock 18 o'clock November 21, 2005.

<% Response.ExpiresAbsolute="November 21,2005 20:18:15# %>

Note: If the Expireabsolute property is set more than once on the page, the date and time of the earliest expiration will prevail.

Iv. isclientconnected Properties of Response

This property is used to determine whether the client browser remains connected to the Web server after the last time the Response.Write command was processed on the server. You can use this property to check whether the browser and server are still connected to control whether the script stops executing. Of course, the IsClientConnected property is only available when the last Response.Write is invoked and the browser is still connected. If you run a long-running script without outputting anything, then this property will not work.

See the full set of ASP Getting started tutorials

Related Article

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.