Recommended: ASP 3.0 Advanced Programming (43) 9.3.5 Data Caching First of all, it is important to note that although both data cache and record set cache are used to improve performance, the two are irrelevant. Data cache is a temporary data storage area that allows the use of data in the cache instead of regenerating new numbers.
The ASP Response object is used to send output results from the server to the user.
Example
Writing text using ASP
This example demonstrates how to use ASP to write text.
| The following is the quoted content: <html> <body> <% response.write(Hello World!) %> </body> </html> |
Format text using HTML tags in ASP
This example demonstrates how to use ASP to combine text and HTML tags.
| The following is the quoted content: <html> <body> <% response.write(<h2>You can use HTML tags to format the text!</h2>) %> <% response.write(<p style='color:#0000ff'>This text is styled with the style attribute!</p>) %> </body> </html> |
Redirect users to different URLs
This example demonstrates how to redirect a user to another URL.
| The following is the quoted content: <% if Request.Form(select)<> then Response.Redirect(Request.Form(select)) end if %> <html> <body> <form action=/example/aspe/demo_aspe_redirect.asp method=post> <input type=radio name=select value=/example/aspe/demo_aspe_server.asp> Server Example<br> <input type=radio name=select value=/example/aspe/demo_aspe_text.asp> Text Example<br><br> <input type=submit value=Go!> </form> </body> </html> |
Show random links
This example demonstrates a hyperlink that will display one of the two links each time you load the page.
| The following is the quoted content: <html> <body> <% randomize() r=rnd() if r>0.5 then response.write(<a href='http://CuoXIn.com'>CuoXIn.com</a>) else response.write(<a href='http://www.CuoXIn.com'>www.CuoXIn.com</a>) end if %> <p> This example demonstrates a link, each time you load the page, it will display one of two links: CuoXIn.com! OR www.CuoXIn.com! There is a 50% chance for each of them. </p> </body> </html> |
Control cache
This example demonstrates how to control cache.
| The following is the quoted content: <% Response.Buffer=true %> <html> <body> <p> This text will be sent to your browser when my response buffer is flushed. </p> <% Response.Flush %> </body> </html> |
Clear the cache
This example demonstrates how to clear the cache.
| The following is the quoted content: <% Response.Buffer=true %> <html> <body> <p>This is some text I want to send to the user.</p> <p>No, I changed my mind. I want to clear the text.</p> <% Response.Clear %> </body> </html> |
Stop the script during processing and return the result
This example demonstrates how to interrupt the operation of a script during processing.
| The following is the quoted content: <html> <body> <p>I am writing some text. This text will never be<br> <% Response.End %> finished! It's too late to write more!</p> </body> </html> |
Set how many minutes to cache the page in the browser before it expires
This example demonstrates how to specify the cache time of a page in the browser before it expires.
| The following is the quoted content: <%Response.Expires=-1%> <html> <body> <p>This page will be refreshed with each access!</p> </body> </html> |
Set the expiration date or time of the page cache in the browser
This example demonstrates how to specify the cache time, date or time of a page in the browser
| The following is the quoted content: <% Response.ExpiresAbsolute=#May 05,2001 05:30:30# %> <html> <body> <p>This page will expire on May 05, 2001 05:30:30!</p> </body> </html> |
Check if the user is still connected to the server
This example demonstrates how to check if the user is disconnected from the server.
| The following is the quoted content: <html> <body> <% If Response.IsClientConnected=true then Response.Write(The user is still connected!) else Response.Write(The user is not connected!) end if %> </body> </html> |
Set content type
This example demonstrates how to specify the type of content.
| The following is the quoted content: <% Response.ContentType=text/html %> <html> <body> <p>This is some text</p> </body> </html> |
Set character set
This example shows how to specify the name of a character set.
| The following is the quoted content: <% Response.Charset=ISO8859-1 %> <html> <body> <p>This is some text</p> </body> </html> |
Response object
The ASP Response object is used to send output results from the server to the user. Its sets, properties and methods are as follows:
Share: Make good use of ASP.NET 2.0 URL mapping Introduction: URL mapping is a new feature provided in ASP.NET 2.0. URL mapping technology helps us map a specific URL to another URL. To help understand, let's assume that you have a page called Homepage.aspx on the site to access the homepage, and all users also use it