Some methods and properties of the ASP. NET Response Object

Source: Internet
Author: User

Response object: Output returned to the client

(1), Method:

Response.Write (): Output information to client

Response. Redirect (): redirect

Response . Clear (): clears all HTML pages in the buffer

Response . End (): terminates processing of the ASP and returns to the current state

Response.Flush (): immediately send out the buffer's HTML data

Response. WriteFile () reads a file and writes to the client output stream (in essence: Opens the file and outputs it to the client. )

(2), properties

Response.ContentType The content type of the output stream, such as html (text/html) , normal text (Text/pain), or JPEG picture (image /jpeg).

encoding of the response.contentencoding output stream

Response.Cookies: A collection of Cookies returned to the browser

Response. Buffer : set buffering information, true | false. The default is true

Response. Expires: Gets or sets the number of minutes before the page that is cached on the browser expires, set to 0, expires immediately,

Type of property value : System.Int32

The number of minutes before the page expires.

Response.ExpiresAbsolute : Gets or sets the absolute date and time to remove cache information from the cache

Property value: System.DateTime ; the date and time when the page expires.

Response.CacheControl : The HTTP header, whose value is the cacheability enumeration.

Among them: CacheControl , expiresabsolute , Expires , have been discarded, in order to be compatible with the old version, so write .  

Now control the cache using Response 's Cache property:

Response.Cache : Gets the Web page's Caching policy ( for example, expiration time, privacy settings, and change terms )

Response.Cache.SetExpires(): Set cache expiration date

Response.Cache.SetNoStore():// Sets the Cache-control:no-store HTTP header. and Response.CacheControl = "No-cache"; function as well. /

Requst object: Reads the request message data from the browser.

Post mode data: requst.form[""]

URL data: requst.querystring[]

Both post and URL can be obtained using request["" "

The code to disable caching on the ASP. NET Server is as follows:

          ///caching is disabled on the server side, so server-side caching fails, and every time you need to load code from the server sideResponse.Buffer =true; Response.ExpiresAbsolute= DateTime.Now.AddDays (-1);///to be compatible with older versionsResponse.Cache.SetExpires (DateTime.Now.AddDays (-1)); Response.Expires=0;///to be compatible with older versions///Response.CacheControl ="No-cache";///to be compatible with older versionsResponse.Cache.SetNoStore ();///sets the Cache-control:no-store HTTP header.

The client disables the cache code as follows:

<http-equiv= "Pragma"  content= "No-cache"/>  <  http-equiv= "Cache-control"  content= "No-cache, must-revalidate"  /><http-equiv= "Expires"  content = "0" />

Partial methods and properties of an ASP. Response object

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.