Use 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:
Application,
Request,
Response,
Server, and
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.
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
The session object is used to store data and create a work area for each user who visits and navigates around the web 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
The server object, this is used to contain and send information about the web server itself, perform cleanup of user information no longer needed
Each of the five objects is an object in the object-oriented programming sense and can have its own properties and methods.
An outline of Object-Oriented Programming (OOP)
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.
In procedural programs, procedures are the highest-level elements. They define what the program does. In object-oriented programs, classes are the highest level elements.
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.
Ad ASP.NET Core 3