ASP Built-in Object response

Source: Internet
Author: User
Tags date character set contains flush header
Response| Object Author: scholar

In the previous article, the author gave you a detailed introduction of the ASP built-in object one of the use of Request, I believe that you through a series of practice has been able to master, this article will continue to introduce an ASP's another built-in object Response.

Recently, a lot of friends to "sister son" urged me to speed up the article a SP writing speed, and eagerly asked where there is a SP's textbook. I was deeply affected by the enthusiasm of the study, so I decided to collect some of the SP information information to share with you, but also hope that all the friends can generously collect their own information about A SP to tell the author, thank you. As a result of the current Chinese textbooks on SP A are rare, and the Chinese textbook specially developed for a SP website is unheard of (may be the author's ignorance), but recently heard a book published by Tsinghua University Press about M S InterDev, which has a SP's teaching, and a ctive Server Page 2.0 Chinese Manual, so at present, the author is mainly through the foreign web site to obtain the information and information of SP A, which is the author of the main reason for writing this article. Below I will list some of the more classic a SP sites in B Ookmark:

1, http://www.activeserverpage.com/This is the author visit the most frequent ASP site, is also the world's largest and most full of ASP's Web site, which not only has the latest ASP literature, free components, there is a complete ASP introductory materials, it is more is the central site of the ASP site, through which you can reach countless ASP-related sites.

2, http://www.asphole.com/This is a vulnerability for the ASP site, but it is undoubtedly a complete ASP information site, which not only provided the ASP articles, and components also provide a thorough and exhaustive connection address.

3, Http://www.15seconds.com/faq and Http://www.15seconds.com/search This is an author to see the largest online ASP Exchange site, it has ASP resolving the answer, ASP mailing list information, ASP Skills, you may need to take a few months to finish reading this information. In http://www.15seconds.com/AllComponents.asp you can read the latest ActiveX components and a lot of free components in detail, with very useful documentation and examples.

4, http://www.microsoft.com/workshop/server/asp/aspfeat.asp Everyone knows that the Active server Page is a set of NT IIS-based WEB server environments that Microsoft proposes, so this By Microsoft's own establishment of ASP technical description site, we certainly have to see.

5, http://www.serverobjects.com/Here you can get countless useful ActiveX components, and download their trial version, but unfortunately most of the excellent components are money.

6. http://www.cyscape.com/asp/browscap/Do you remember the Browser Capabilitie component that the author described in ASP2 to identify the client browser version? At this site you can get the latest browscap. INI file, it has every ASP installation when Microsoft did not provide the browser information, so you in the ASP to judge the client browser can be foolproof.

7, Http://www.microsoft.com/data/ado/ASP the most powerful and convenient function is the connection with the database, through the ASP built-in ActiveX components, we can easily connect the WEB with all ODBC-compatible databases, You can get a lot of practical ADO data on this Microsoft site.

8, http://www.cobb.com/m_sbn4/a good ASP forum, where you can paste your questions, read other people's Questions and answers. Below, we begin to learn another ASP's Response object.

Instead of obtaining client HTTP information, the Response object is used to control the information sent to the user, including sending the message directly to the browser, redirecting the browser to another URL, or setting the value of the cookie.

Grammar Response.collection|property|method

One, property

1, Buffer buffer property indicates whether to buffer page output. When the page output is buffered, the server sends the response to the client browser only after all server scripts for the current page have been processed or the Flush or End method is invoked, and the server will no longer be able to set the buffer property after it has been sent to the client browser. You should therefore call Response.Buffer on the first line of the. asp file.

2. The Charset Charset property attaches the character set name to the back of the Content-type header in the Response object. For ASP pages that do not contain the Response.Charset property, the Content-type title will be: content-type:text/html.

We can specify Content-type headers in the. asp file, such as:

<% response.charset= "gb2312")%>

The following results are produced:

content-type:text/html; charset=gb2312

Note that the feature inserts it into the Content-type header, regardless of whether the character set represented by the string is valid. And if a page contains more than one tag that contains Response.Charset, each Response.Charset replaces the previous charsetname. In this way, the character set is set to the value specified by the last instance of Response.Charset in the page.

3. The ContentType ContentType property specifies the HTTP content type of the server response. If ContentType is not specified, the default is text/html.

4. The Expires Expires property specifies how long it will be before the page that is cached on the browser is expired. If a user returns to this page before a page expires, the page in the buffer is displayed. If you set response.expires=0, you can make cached pages expire immediately. This is a more practical property, when the customer through the ASP's Landing page into the Web site, you should use this property to make the landing page expire immediately to ensure security.

5, ExpiresAbsolute and Expires properties different ExpiresAbsolute property specifies the exact expiration date and time of the page that is cached in the browser. The page in the cache is displayed if the user returns to the page before it expires. If no time is specified, the home page expires at midnight on the same day. If no date is specified, the home page expires at a specified time on the day the script is run. The following example specifies that the page expires in 30 seconds on December 10, 1998 9:00.

<% response.expiresabsolute= #Dec 12,1998 9:00:30#%>

Second, the method

1. Clear clears all HTML output in the buffer with the clean method. However, the clear method clears only the response body and does not clear the response header. You can use this method to handle error conditions. However, if Response.Buffer is not set to TRUE, this method will cause a run-time error.

The 2-end method causes the WEB server to stop processing the script and return the current result. The remaining content in the file will not be processed. If the Response.Buffer is set to TRUE, the call to Response.End will buffer the output.

3. The Flush Flush method immediately sends the output in the buffer. If Response.Buffer is not set to TRUE, the method causes a run-time error.

4. The Redirect Redirect method causes the browser to immediately redirect to the URL specified by the program. This is also a method that we often use so that programmers can specify different pages for different customers depending on the customer's response, or different pages for different situations. Once the Redirect method is used, any response body content that is explicitly set in the page is ignored. However, this method does not send the client a different HTTP header for the page set, resulting in an automatic response body containing the redirected URL as a link. The Redirect method sends the following explicit caption, where the URL is the value passed to the method. Such as:

<% Response.Redirect ("www.chinabyte.com")%>

5. The write write method is one of the most common methods we usually use to write the specified string to the current HTTP output.

Third, set Response



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.