ASP   «Prev  Next»

Lesson 10The ASP object model
ObjectiveUse ASP's objects to simplify writing ASP operations.

ASP Object Model

The interaction between Web clients and servers is complex, with many messages passed between the two. However, most of the time we only need to work with one part of this complex interaction, for example a cookie sent by a user's browser to our Web server.
One of the goals of ASP, and object-oriented programming in general, is to hide unneeded complexity from the developer.
The designers of ASP have built a model of this complex interaction in the ASP object model. As we work with ASP, we will do so through the five "built-in" objects of ASP:
  1. Application,
  2. Request,
  3. Response,
  4. Server, and
  5. Session.


This SlideShow below describes the five objects of the ASP object model that represent the categories of operations during a browser-server dialog:
The request object, this is used to receive data from the client's browser and computer, including cookies, files, and HTML forms. It provides a way for the server to store and retrieve the received data.
1) The request object, this is used to receive data from the client's browser and computer, including cookies, files, and HTML forms. It provides a way for the server to store and retrieve the received data.

Response object is used to send data or HTML code from directories or memory locations on the server back to the client browser and computer
2) Response object is used to send data or HTML code from directories or memory locations on the server back to the client browser and computer, including cookies and Web pages containing the results of ASP scripts.

The session object is used to store data and create a work area for each user who visits and navigates around the web site. It provides the continuity (state) that is lost in static HTML pages.
3) The session object is used to store data and create a work area for each user who visits and navigates around the web site. It provides the continuity (state) that is lost in static HTML pages when a user moves from one HTML page to another and can initiate special routines or display special pages when a user first arrives at the site and exits from the site.


Application object is used to allow more than one user at a time to run a web application, which can be a separate program linked to the Web pages or the Web pages and ASP scripts themselves.
4) Application object is used to allow more than one user at a time to run a web application, which can be a separate program linked to the Web pages or the Web pages and ASP scripts themselves. Without this, one user would be setting and resetting counters and calculations that were in use by another user. An important consideration in an online store Web site.

The server object, this is used to contain and send information about the web server itself, perform cleanup of user information no longer needed, and create and terminate input/output connection to user files and other applications like database records.
5) The server object, this is used to contain and send information about the web server itself, perform cleanup of user information no longer needed, and create and terminate input/output connection to user files and other applications like database records that cannot or should not be shared among multiple users.

ASP Five Object Model

This section describes the intrinsic COM objects (ASP built-in objects) that are available to ASP pages. Using ASP built-in objects, you can access to information regarding the Web server,
  1. the client who is accessing a Web page,
  2. the Web application that contains the Web page, and
  3. the fields in the HTTP request and response streams.
The ASP built-in objects are organized by the type of information they contain.
The information in ASP built-in objects can also be obtained in a COM component or an ISAPI application. The following table lists the technologies from which ASP built-in objects can be accessed and how to access them.

ASP.NET Core 3

An outline of Object-Oriented Programming (OOP)

Each of the five objects is an object in the object-oriented programming sense and can have its own properties and methods.
In procedural programming, you think about the algorithms and data structures that are used to model the problem and then divide the problem into a series of ever-smaller procedures. Object-oriented programming (OOP) is a programming language model organized around objects rather than "actions" and data rather than logic. Historically, a program has been viewed as a logical procedure that takes input data, processes it, and produces output data. The programming challenge was seen as how to write the logic, not how to define the data. Object-oriented programming takes the view that what we really care about are the objects we want to manipulate rather than the logic required to manipulate them. Examples of objects range from humans (described by name, address, and so forth) to cyborgs (whose properties can be described and managed) down to the integrated circuits (such as CPU and ALU).
In object-oriented programming, you think about the overall system you are modeling and how the elements in the system interact with each other. When programming using the object-oriented paradigm, classes are the highest level elements. In object-oriented programs, In procedural programs, procedures are the highest-level elements. They define what the program does.
Classes correspond to real-world entities such as employees or automobiles. An object is one instance of a class, much as 3 is an instance of a number and hello is an instance of an English word. There are rules about how to add and subtract numbers, and they apply to all numbers. When you define a class, you are setting the rules for all the members (objects) of that class.
Objects combine data (also called attributes, variables, and state) with behavior (also called methods, functions, and operations). An object holds information, and can do things with that information on request. The application of OOP to ASP objects is that each object we will encounter has properties and methods already defined. When you set a property (attribute) equal to a variable of the appropriate type and refer to one of the object's methods a known and consistent operation will occur on, or using, that property (or those properties).
In later modules, we will cover each of the objects in detail. Compare scripting alternatives for embedding programs in HTML.

SEMrush Software