Although many Web sites that use ASP do not use components at all, in this article, ASP is assumed to be a bridge between Internet clients and components.
ASP and components division services
ASP is most commonly used to create HTML or XML files for use by clients on servers, so we mainly discuss this usage scenario. This raises a common question: If ASP pages are on the server, then do they belong to part of the business layer? In the component world, the answer is usually no. While ASP does run on the server and may be in the same space as the application server, this does not make it part of the business logic.
With user interface tools growing or as more business-to-business solutions are enabled, having this clear distinction will pay off a huge reward.
Having said that, let's look at some of the most important business layer and presentation layer division criteria:
Separate UI code from business logic. This includes writing code coupled to the UI, such as using an MTS object that uses an ASP internal component to separate it from the business logic code, as if it were in a different DLL.
Separate transactions from ASP pages. Transaction ASP is very good in some cases, but components and multi-tier applications change this. Components should not rely on the client layer to manage their transactions and business logic semantics.
Place the representing component (component that uses request and response) in the same machine and/or process as the Web server. If an object using the ASP internal component object is placed on a remote machine, all calls to the internal component will occur in a callback form. The COM+ server that calls the IIS client is a COM+ server, which significantly reduces performance and complicates security configuration. These tweak objects can be placed in a COM+ application marked "Library Activation".
ASP exists on the server, so the ASP page must comply with resource sharing rules and keep in mind scalability. Please see the details below:
In a "session", management should try to avoid user-specific status.
Keep ASP stateless and allow resource pools where possible.
Operation method
When evaluating whether a code segment belongs to business logic or presentation layer, ask yourself, "If I have to replace my ASP page with a button-type phone application, is that code still useful?" If the answer is "Yes", you can try dividing it into business logic code or user interface helper code.
If the code cannot be used after changing the client, or if it is a helper for constructing the user interface, the code belongs to the representation service layer. It is in the ASP page, or in a component that uses the ASP internal components. It does not belong to the business object component.
Understand the difference between desktop and ASP client
ASP is a special client of components, unlike traditional single-threaded Win32 applications on the desktop. The main differences are summarized as follows.
Thread Management: ASP is a multi-threaded client. This means that there can be many concurrent activities running together, perhaps handling different ASP pages at the same time. This means that the object cannot be made to falsely claim that it is the only user to exclusively occupy the system. Doing this can cause unexpected reactions, for example, to develop a bad habit of storing objects in an ASP session or application variables.