October 17, 2002 - Using the Global Response Object | WebReference

October 17, 2002 - Using the Global Response Object

Yehuda Shiran October 17, 2002
Using the Global Response Object
Tips: October 2002

Yehuda Shiran, Ph.D.
Doc JavaScript

ASP.NET inherited the built-in objects from ASP. These objects are global in the sense that you don't need to construct them or pass them around; they are always there. There are five built-in objects: Request, Response, Server, Session, and Application.

The Response object is used to pass information to the user. These are its properties:

Buffer: a Boolean directing the server (if true) to buffer its output until all server scripts on the current page have been processed, or until the Flush or End method has been called.
  • ContentType: the type of content sent back (text/HTML, Excel, etc.)
  • Expires: the time in minutes after which the user's cache for this page is invalid.
  • ExpiresAbsolute: the absolute date and time for expiration of the user's cache for this page.
  • Status: returns the status line (defined in the HTTP specification of the server).

    The Response object supports the following methods:

    AddHeader: adds an HTML header with a specified string value.
  • AppendToLog: appends a string to the Web server log file.
  • BinaryWrite: write binary data (i.e. Excel file).
  • Clear: clears any buffered HTML output.
  • End: stops processing the script.
  • Flush: sends all the information in the buffer.
  • Redirect: redirects the user to another URL.
  • Write: writes into the HTML stream. You can use Response.write("Hello There") or <%"Hello There"%>

    The Response object includes one collection, Cookies. In IBuySpy, we use these cookies to persistently save the user name:

      Response.Cookies["IBuySpy_FullName"].Value = Server.HtmlEncode(Name.Text);