The core APIs of ASP consists of a few intrinsic objects (Request, Response, Server, etc.) and their associated methods . With the exception of a few simple changes, these APIs will continue to function correctly under ASP.NET Application Object The application object can be used to share information among all users of a given application. An ASP-based application is defined as all the .asp files in a virtual directory and its subdirectories. Table 7-3 lists the application objects found in ASP and ASP.NET. Table 7-3. Comparing Application Objects in ASP and ASP.NET Application Object | ASP | ASP.NET | Collections | | | Contents (Key) | A collection of all of the items, which have been created and added to the application object during client sessions through script commands, such as the Server.CreateObject, rather than by using the HTML <OBJECT> tag. | Supported. | StaticObjects (Key) | A collection of all of the items that have been created and added to the application object during client sessions by using the HTML <OBJECT> tag rather than using script commands. | Supported. | Methods | | | Contents.Remove | The Contents.Remove method is used to remove a single item from a Contents collection. | Supported. | Contents.RemoveAll | The Contents.RemoveAll method is used to remove all items from a Contents collection. | Supported. | Lock | The Lock method prevents all other users from making changes in the application object. | Supported. | Unlock | The Unlock method allows any user to have access to any of the Application object properties in order to make changes. | Supported. | Events | | | OnEnd | The OnEnd event occurs when the application quits. This should not occur unless all user sessions are over. The signal of this event will run a handler script in the Global.asa file, if the script exists. | Supported. The event handler will be written in global.asax . | OnStart | The OnStart event occurs before the start of any new session by a user (i.e., before the application object is first referenced). The signal of this event will run a handler script in the Global.asa file, if the script exists. | Supported. The event handler will be written in global.asax . | Request Object The request object retrieves the values that the client browser passed to the server during an HTTP request. Table 7-4 lists the request objects in ASP and ASP.NET. Table 7-4. Comparing Request Objects in ASP and ASP.NET Request Object | ASP | ASP.NET | Collections | | | ClientCertificate (Key) | The ClientCertificate collection property contains the values of the client certification fields of the request, and returns an array. | Supported; returns HttpClientCertificate object. | Cookies (Key) | The Cookies collection property contains the values of the cookies sent in the request, and returns array. | Supported; returns HttpCookieCollection object. | Form (Key) | The Form collection property contains the values of the <FORM> elements posted to a form using the POST method. | Returns Array of String in ASP; returns NameValue Collection in ASP.NET. | QueryString (Key) | The QueryString collection property contains the values of the variables in the HTTP query string, which are the statements that follow a question mark. | Returns Array of String in ASP; returns NameValue Collection in ASP.NET. | ServerVariables | The ServerVariables collection property contains the values of server environmental variables. This allows access to the HTTP headers. | Supported. ASP.NET provides 49 environmental variables as compared to ASP, which provides 43. | Property | | | TotalBytes | The TotalBytes property specifies the total number of bytes sent in the body of the HTTP request. | Supported. | Methods | | | BinaryRead | The BinaryReadmethod retrieves the data that was sent to the server from the browser as part of a POST request and returns the number of bytes read, return type variant. | Supported; returns Byte array. | Response Object The response object is used to send output to the client. Table 7-5 lists the response objects in ASP and ASP.NET. Table 7-5. Comparing Response Objects in ASP and ASP.NET Response Object | ASP | ASP.NET | Collections | | | Cookies (Key) | The Cookies collection property contains the values of the cookies sent in the request, and returns an array. | Supported; returns collection of HttpCookie objects. | Property | | | Buffer | The Buffer property tells whether the page output being sent to the browser is buffered. | Supported. | CacheControl | The CacheControl property determines whether a proxy server can cache the ASP page. | Supported but deprecated in favor of HttpCachePolicy methods. | Charset | The Charset property appends the name of the character set being used to the content-type header contained in the response object | Supported. | ContentType | The ContentType property specifies the HTTP content type and subtype for the response header. | Supported. | Expires | The Expires property specifies the length of time in minutes until a cached page on the browser expires. | Supported but deprecated in favor of HttpCachePolicy methods. | ExpiresAbsolute | The ExpiresAbsolute property specifies a date and time when a cached page on the browser will expire. | Supported but deprecated in favor of HttpCachePolicy methods. | IsClientConnected | The IsClientConnected property indicates whether the browser has disconnected from the server since the last Response.Write. | Supported. | PICS | The PICS property specifies the value of a PICS rating label for a document or a site. | Not Supported. | Status | The Status property specifies the value of the status line returned by the server. | Supported. | Methods | | | AddHeader | The AddHeader method adds a new named HTTP header with a specific value to the response. | Supported only for compatibility with previous versions of ASP. For ASP.NET use AppendHeader. | AppendToLog | The AppendToLog method adds a string to the end of an entry in the Web server log for this request. | Supported. | BinaryWrite | The BinaryWrite method sends specific data to the current HTTP output without any character conversions, and writes variant array of unsigned integers. | Supported; writes Byte array. | Clear | The Clear method clears (erases) any buffered HTML output. | Supported. | End | The End method causes the Web server to stop processing the script and to return the current results without processing the rest of the file. | Supported. | Flush | The Flush method sends the contents of the buffer. | Supported. | Redirect (URL) | The Redirect method tries to connect the browser to a different URL. | Supported. | Write (variant) | The Write method sends any specified variant to the browser. | Overloaded, takes any of Char, Object, String, Char Array. | Server Object The server object provides access to methods and properties on the server. Most of these methods and properties serve as utility functions. Table 7-6 lists the server objects in ASP and ASP.NET. Table 7-6. Comparing Server Objects in ASP and ASP.NET Server Object | ASP | ASP.NET | Property | | | ScriptTimeout | The ScriptTimeout property is the amount of runtime in seconds for a script before it terminates. | Supported. | Method | | | CreateObject (ProgID) | The CreateObject method creates an instance of an object to use in an ASP page. | Overloaded; takes ProgID as before and also takes Type object. | Execute (Path) | The Execute method allows you to call another ASP page from inside an ASP page. When the called ASP page completes its tasks , you are then returned to the calling ASP page. | Overloaded; takes path as String as before and now takes String and TextWriter object. | GetLastError | The GetLastError method returns an ASPError object that describes any preprocessing, runtime, or script compiling errors that occurred. | Supported; returns Exception object. | HTMLEncode | The HTMLEncode method applies HTML syntax to a specified string of ASCII characters . | Overloaded; takes String and TextWriter object in addition to the previous form. | MapPath (Path) | The MapPath method maps a relative or virtual path to a physical path. | Supported. | Transfer (Path) | The Transfer method allows you to transfer all of the state information for all of the built-in objects from one ASP page to another. Unlike the Execute method, when the ASP page that you have transferred to is finished, you do not return the original ASP page. | Supported. | URLEncode (String) | The URLEncode method applies URL rules to a specified string of ASCII characters. | Overloaded; takes String and TextWriter object in addition to the previous form. | ASPError Object The ASPError object can be used to obtain information about an error condition that has occurred in script in an ASP page. The ASPError object is returned by the Server.GetLastError method in ASP. The ASPError object exposes read-only properties. Table 7-7 lists the ASPError objects in ASP and ASP.NET. Table 7-7. Comparing ASPError Objects in ASP and ASP.NET ASPError Object | ASP | ASP.NET | Property | | | Description | The Description property returns a string that is a short description of the error. If you want a longer description, use the ASPDescription property. | Supported. | HelpContext | Returns or sets an Integer containing the context ID for a topic in a Help file. | Supported. | HelpFile | Returns or sets a String expression containing the fully qualified path to a Help file. | Supported. | Number | The Number property returns a long integer defining the standard COM error code returned by a COM component. | Supported. | Source | The Source property returns a string with the actual line from the source code where the error occurred (if available). | Supported. | Methods | | | Clear | Clears all property settings of the Err object. | Supported. | Raise | Explicitly raises an error. | Supported. | Session Object The session object is used to store information needed for a particular user session. Variables stored in the session object are not discarded when the user jumps between pages in the application; instead, these variables persist for the entire user session. The session object has been discussed in detail in earlier sections. |