1. Technology
Send to a Friend via Email

ASP Built-In Objects


When you write ASP you generally use objects to create and manipulate your pages. There are several objects that are intrinsic within the IIS object model. This means that you can use these objects in your ASP pages without any additional components required.

Application Object

ASP defines an application as all the files that can be accessed in any given directory and all its sub-directories. For example, if I had ASP pages in a directory /database, all pages within that directory would be a part of the "database" application. Whenever an ASP page is opened the Application object is initialized. You can use the Application object as global variables for your ASP documents. Global variables can be powerful, but they can also cause problems, so be careful you know the scope of your variable before you are going to use it.

ASPError Object

The ASPError object was introduced in ASP 3.0. This allows you to view information about the last ASP error that occurred in the current session. This detailed information is vital to debug ASP applications.

Request Object

This is one of the more useful objects of ASP. It gives you access to the user's HTTP request header and body. This allows you to react to actions and decisions of your user. You can create dynamic Web pages and do things like update a database based upon input from the user.

One use of the Request object is to read cookies. To read a cookie with ASP, simply use the Request object with the "Cookies" collection, and the name of the cookie you want to read:
  strCookie = Request.Cookies.Item("cookiename")

You can also use the Request object to retrieve information put in an HTML form. Read the form entries in a similar way to reading cookies:
  strTextentry = Request.Form.Item("textfieldname")

Response Object

This is an object that is somewhat the opposite of the Request object. This gives you control over the data types sent to the client in the HTTP response and controls when and how that data is sent.

This is usually used to set cookies:
  Response.Cookies("cookiename") = "Jennifer"

You can also control the caching of the page. If you set the CacheControl to "Public" proxy servers can cache your page, and the page will load faster. The default setting is "Private":
  Response.CacheControl = "Public"

Use ASP objects to write your ASP scripts quickly and efficiently. And with these internal objects you can create powerful pages that are dynamic and interactive.

Previous Features

©2014 About.com. All rights reserved.