ASP development guidelines

zhaozj2021-02-16  97

The application server is, or will eventually be used by the web server, which is usually an IIS computer running the ASP page. ASP is the only client for your object. It brings special threads and safety considerations.

Although many Web sites using ASP do not have components at all, in this article, assuming ASP is a bridge between the Internet client and components. The following ASP Component Guidelines (English)

Division between ASP and components

ASP is most commonly used to create HTML or XML files for clients on the server, so we mainly discuss this usage program. This will lead a common problem. If the ASP page is on the server, do they belong to a part of the business layer? In the component world, the answer is usually. Although ASP is indeed running on the server, and may be with the application server in the same space, this cannot make it part of the business logic.

With the development of user interface tools or with more business to business programs, this clear difference will be huge return.

Say this, let us see some of the most important business strata and representation layer division guidelines:

Let the UI code are separated from the business logic. This includes writing code coupled to the UI, such as the MTS object using the ASP internal components, so that it is separated from the business logic code, as in different DLLs. Separate the transaction with the ASP page. Transaction ASP is very good in some cases, but components and multi-layer applications change this. Components should not rely on their transactions and business logic semanties by the client layer. Place the components (components that use requests and responses) and web servers in the same machine and / or process. If you will be placed on a remote machine using an object of an ASP internal component object, all calls to the internal components will occur in a callback form. Calling the IIS client is a COM server, which significantly reduces performance and complicates security configuration. These adjustments can be placed in a COM application labeled "library activation".

The ASP exists on the server, so the ASP page must meet the resource sharing rules and remember scalability. Please see the details below:

In "Sessions", management should try to avoid user-specific status. Keep the ASP stateless and allow the resource pool to be allowed.

Operation method

When evaluating if a code segment belongs to business logic or representing a layer, please ask yourself, "If I have to use the button phone application instead of my ASP page, if the code is also useful?" If the answer is "Yes", So you can try to divide it into business logic code or user interface helper code.

If the code cannot be used after the client is changed, or if it is a help device that constructs the user interface, the code belongs to the representation of the service layer. It is in the ASP page, or in components that use the ASP internal components. It does not belong to business object components.

Understand the difference between desktop and ASP client

The ASP is a special client of the component, which is different from traditional single-threaded WIN32 applications on the desktop. The main difference is summarized below.

Thread management: ASP is multithreaded client. This means that there are many concurrent activities to run together, may handle different ASP pages at the same time. This shows that the object is not called by the only user to exclusive system. This may have an unexpected reaction, for example, develop a bad habit: store the object in an ASP session or application variable. Security environment: ASP is performed by Internet Information Services 5.0 in the Web site, low, medium, and high isolation. Even these Web sites can have different security settings, allowed or refused anonymous access, verifying customers, and more. All of these settings have a large number of options, that is, different user accounts ultimately use your object. Easy to grow: This is not a technical problem, but a sub-effect of the facility provided by the web application. Traditionally, the user base is added to the desktop application, requiring a closer plan to transfer to the known quantity client. The ASP has changed the process. After starting and running, the ASP-Visual Basic app can easily open for local or worldwide staff, all business partners and all customers. You can use this way - a single email with hyperlinks can increase the user based on ten times. Is your app ready for this? The only way to understand the Web site to achieve the actual performance expectation. For more information on intensity testing, see the "Application Life Cycle" section. How should I use Visual Basic objects within ASP? Create and cancel your objects within the page. That is, the ASP page is not status as much as possible, depending on the session or application variable in the temporary state. Do not store objects in a session or application variable. This locks the ASP thread to your session and cancels the expected value of all scalability. That is, the number of users processed by the web server will not exceed dozens. If you need to store content in a session or application, make it a data instead of an object.

There are many other guidelines that can be observed. We recommend that you read the columns "Servin 'IT Up" written by J. D. Meier on MSDN Voices. This column includes a lot of technologies, practices, and techniques to help develop scalable, reliable ASPs and component applications.

reference

MSDN Voices: Servin's IT Up Column (English) Seminaronline: Using Custom COM Components Using Custom COM Components (English) MSDN MSDN

Do not store the reference to the VB object in a session or application

All Visual Basic 6.0 components are "unit threads", that is, they are running in the STA unit. This means that if you create an object in the thread, all calls to the object must be served with the same thread. Many threads (from concurrent Web site users) use STA objects, which cause a series of activities, which may become bottlenecks in the application.

In addition, the STA object created with Server.CreateObject is stored within the session, which can effectively link the execution thread to the current user, so that the maximum number of concurrent users of the application is limited to the default 20xN (N = processor number).

Operation method

If you are not required to make the object in accordance with our recommendations, you do not need to store a reference for client multiplexing and store them within the application range. The client will be able to create, use and cancel their own objects independently. This reduces the need to maintain a specific object of the session, because they do not retain the state of the session.

The recommended way is to enable the object state, which access the database or other storage area (such as cookies and ldap) when needed.

If you need to use a session or application range, use the data, not the object to process the data, stored here. You can create a class to encapsulate the processing of the desired value. reference

Information: Do not store Sta objects (Q243543) (English) PRB in a session or application: Store the STA COM component in a session, which is locked in a single thread (Q243815) (English) information: Component thread under ASP Model summary (Q243544) (English)

Learn new content in IIS 5.0

Internet Information Server 5.0 adds many new features. These improvements have been written in the MSDN article of J. D. Meier: along the ASP (English) in IIS 5.0. Below is an overview of the most important improvements in this article.

Improved, excellent performance Server.Transfer and Server.execute methods Centralized Error handling improved browser features Improved script engine regular expression analyzer and ADO record set XML function integration new security, buffer, isolation, and management Features

转载请注明原文地址:https://www.9cbs.com/read-12823.html

New Post(0)