ASP Objects

1. Session Object
2. Application Object
3. Server Object
4. Request Object
5. Response Object
6. Object Context
7. Error Object

Session Object
The Session object carries values needed by a single client over the entire session, which may be several pages.
Collections
Contents contains all the non-object session variables.
StaticObjects contains all the session objects.
Properties
CodePage is used to specify the page that defines the character set.
LCID specifies the location identifier to be used.
SessionID returns a numerical session number.
Timeout specifies the time, in minutes, until the session timeout.
Methods
Abandon causes the session object to be destroyed on completion of the current page.
Contents.Remove(item) removes the item from the Contents collection. item is either a string or an integer representing an index number.
Contents.RemoveAll removes all items from the Contents collection.
Events
Session_OnEnd occurs when a session ends, either by Abandon or a timeout.
Session_OnStart occurs when a new session is created.

Application Object
The Application object is used to share data among several users visiting the same group of pages. Only one instance of the Application object is created per application, and it is shared among all the clients accessing that application.
Collections
Contents contains all the non-object application variables.
StaticObjects contains all the application's objects.
Methods
Contants.Remove(item) removes the item from the Contents collection. item is either a string or an integer representing an index number.
Contents.RemoveAll removes all items from the Contents collection.
Lock prevents all other clients from modifying values in the Application object.
Unlock releases the lock and allows other clients to modify values in the Application object.
Events
Application_OnStart occurs when an application is started before the session starts.
Application_OnEnd occurs when the application quits, after all the sessions have ended.

Server Object
The Server object provides access to some basic tools on the server.
Properties
ScriptTimeout specifies the amount of time, in seconds, a script will be allowed to run before timing out.
Method
CreateObject(componentname) is used to instantiate a server component.
Execute(path) executes an ASP page as though it were part of the calling page. This is more flexible than server-side includes because the filename can be dynamically generated.
GetLastError() returns an instance of the ASPError object that describes the last error.
HTMLEncode(string) encodes string so that the browser will not interpret it as HTML.
MapPath(path) maps the specified virtual path, either a relative one or an absolute one, into a physical path.
Transfer(path) transfers control to another ASP page without creating a separate object context.
URLEncode(string) applies encoding rules so that the string may be put safely into the query string.

Request Object

The Request object is used to access data that the client sent when it requested the current page.
Collections
ClientCertificate contains certification values sent by the client.
Cookies is used to read in the values of cookies that were sent in with the request.
Cookies(name).HasKeys allows you to find out whether the specified cookie has keys.
Form contains the values entered into a form that uses the POST method.
QueryString contains the values passed to the page on the query string. (or from a form using the GET method)
ServerVariables contains the values of the environment variables.
Properties
TotalBytes specifies the number of bytes sent in the client's request.
Methods
BinaryRead retrieves the data sent by the client in a POST request and stores it into a special kind of array called a SafeArray.

Response Object
The Response object is used to send output to the client. It also allows you to control how and when the output is sent.
Collections
Cookies is used to set cookie values.
Cookies(name).Domain allows you to specify that only a particular domain can access the cookie.
Cookies(name).Expires allows you to set the date that the cookie expires. If it is not set, the cookie will expire when the session ends.
Cookies(name).HasKeys allows you to find out whether the specified cookie has keys.
Cookies(name).Path allows you to specify that only a particular path can access the cookie. The default of this is the application path.
Cookies(name).Secure allows you to specify whether extra precautions are taken to ensure the security of the cookie.
Properties
Buffer specifies whether buffering is turned on.
CacheControl specifies whether proxy servers are able to cache the page.
Charset(name) appends the name of the character set (specified by name) to the content-type header.
ContentType is used to specify the HTTP content type for the output. Default is text/HTML.
Expires specifies the length of time, in minutes, before the cached version of the page expires.
ExpiresAbsolute specifies the date and time when the cached version of the page expires.
IsClientConnected is a Boolean value that indicates whether the client is still connected to the server.
Pics(label) will add label to the PICS-label response header.
Status is the value of the server's status line.
Methods
AddHeader name, value adds an HTML header with the specified name and value.
AppendToLog string adds string to the end of the server query log entry.
BinaryWrite data writes data to the HTTP output without performing any character conversion.
Clear deletes all the buffered output that has not been sent.
End halts execution of the script and sends all buffered output.
Flush sends all the buffered output and clears the buffer.
Redirect path tells the client to make a request for the page specified by path.
Write string writes to the HTTP output.

ObjectContext Object
The ObjectContext object is used to link ASP and the Microsoft Transaction Server.
Methods
SetAbort aborts the transaction.
SetComplete declares that the transaction should complete, overriding any prior use of SetAbort.
Events
OnTransactionAbort occurs if the transaction is aborted.
OnTransactionCommit occurs after the transaction commits.

ASPError Object
The ASPError object was introduced in IIS 5.0. It allows you to obtain information about errors that have occurred in the script.
Properties
ASPCode returns a string with the error code.
ASPDescription is a long string that describes the error that occurred.
Category returns a string indicating whether the error is from the scripting language, ASP, or an object.
Column returns the column number responsible for the error.
Description is a short string that describes the error that occurred.
File returns a string indicating the name of the file responsible for the error.
Line returns the line number responsible for the error.
Number returns the error number returned by a COM component.