ASP development guidelines

Source: Internet
Author: User
ASP development guidelines

The application server is or will eventually be used by the Web server, which is usually the IIS computer running ASP pages. ASP is the unique client of your object. It brings special thread and security considerations.

Although many web sites that use ASP do not need components at all, this article assumes that ASP is a bridge between Internet clients and components. The following ASP Component standards (English) are provided

Division between ASP and components

ASP is most commonly used to create HTML or XML files for the client on the server. Therefore, we mainly discuss this usage scheme. This raises a common problem. If ASP pages are on the server, are they part of the business layer? In the component world, the answer is usually. Although ASP does run on the server and may be in the same space as the application server, it cannot be part of the business logic.

With the development of user interface tools or the activation of more businesses for business solutions, such a clear difference will return a huge deal.

Now let's look at some of the most important business layer and presentation layer criteria:

  • Separates the UI code from the business logic. This includes writing code coupled with the UI, such as using the MTS object of ASP internal components to separate it from the business logic code, as in different DLL.
  • Separates transactions from ASP pages. Transaction ASP is very good in some cases, but the component and multi-tier application will change this situation. Components should not rely on the client layer to manage their transactions and business logic semantics.
  • Place the component that represents the request and response on the same machine and/or process as the web server. If you place the object using the ASP internal component object on a remote machine, all calls to the internal component will occur in the form of callback. The IIS client is called on the COM + server, which significantly reduces the performance and complicate the security configuration. You can place these adjustment objects in the COM + application marked as "database activation.

ASP exists on the server. Therefore, ASP pages must comply with resource sharing rules and remember scalability. See the following details:

  • In sessions, management should avoid user-specific States as much as possible.
  • Keep ASP stateless and allow resource pools whenever possible.

Operation Method

When evaluating whether a code segment belongs to the business logic or the presentation layer, may I ask myself, "If I have to replace my ASP page with a key-based phone application, will this code still be used ?" If the answer is "yes", 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 helper that constructs the user interface, the Code belongs to the service layer. It is either on an ASP page or on a component that uses an ASP internal component. It is not a business object component.

Understanding the differences between desktop and ASP clients

ASP is a special client of components, different from the traditional single-threaded Win32 application on the desktop. The main differences are as follows.

  • Thread management: ASP is a multi-threaded client. This means that many concurrent activities can run together and may process different ASP pages at the same time. This means that the object cannot be called a unique user to exclusively occupy the system. This may have an unexpected response, for example, developing a bad habit: storing objects in ASP sessions or Application variables.
  • Secure Environment: ASP is executed by Internet Information Services 5.0 on the web site, with isolation of low, medium, and high levels. Even these web sites can have different security settings, allow or reject Anonymous Access, and authenticate customers. All these settings generate a large number of solutions, that is, different user accounts ultimately use your objects.
  • Easy growth: this is not a technical issue, but a secondary effect of the facilities provided by web applications. Traditionally, adding a user base for desktop applications requires careful planning of outbound traffic to a known number of clients. ASP has changed this process. After the ASP-Visual Basic Application is started and run, it can be conveniently opened for all local staff, all business partners, and all customers around the world. You can use this method to describe that a single email with a hyperlink can increase the user base by 10 times. Are your applications ready for this? The only way to understand this is to perform a Web site strength test to obtain the expected value of the actual performance. For more information about strength testing, see the "Application lifecycle" section.

In ASP, how should I use visual basic objects? Create and cancel your objects within the scope of the page. That is to say, try to make the ASP page stateless and only rely on session or Application variables in the temporary state. Do not store objects in session or Application variables. This locks the ASP thread to your session and cancels the expected values of all scalability. That is to say, the number of users processed by the Web server cannot exceed dozens. If you need to store content in sessions or applications, make it data rather than an object.

There are also many other rules that can be followed. We recommend that you read the "servin it up" column written by J. D. Meier on msdn voices ". This column includes a large number of techniques, practices, and techniques to help develop scalable and reliable ASP and component applications.

Reference

Msdn Voices: servin' it up column (English)
Seminaronline: use custom COM components in ASP)
Msdn magazine (English)

Do not store references in VB objects in sessions or applications

All Visual Basic 6.0 components are "unit Threads", that is, they all run in the sta unit. This means that if an object is created in the thread, all calls to the object must use the same thread service. Many threads (from concurrent web site users) use the same instance of the sta object, which may lead to a series of activities and may become bottlenecks in applications.

In additionServer. CreateobjectCreatedStaObject To effectively contact the current user, so as to limit the maximum number of concurrent users of the application to the default 20 xN(N= Number of processors ).

Operation Method

If you follow our advice to make objects stateless, you do not need to store references for reuse by clients and store them within the scope of applications. Clients can independently create, use, and cancel their own objects. This reduces the need to keep session-specific objects because they do not keep session-specific States.

The recommended method is to make the object stateless and access the database or other storage areas (such as cookies and LDAP) as needed ).

If you want to use data within a session or application range, store the data instead of the data processing object here. You can create a class to encapsulate the processing of the required values.

Reference

Info: Do not store the sta object (q243543) in sessions or applications)
PRB: stores the sta COM component in a session and locks the session in a single thread (q243815)
Information: component thread model overview under ASP (q243544)

Learn New Content in IIS 5.0

Internet Information Server 5.0 has added many new features. These improvements have been written into the msdn document J. D. Meier: Follow ASP in IIS 5.0 ). The following is an overview of the most important improvements in this article.

  • Improved and outstanding performance
  • Server. Transfer and server. Execute Methods
  • Centralized error handling
  • Improved browser Functions
  • Improved Script Engine
  • Regular Expression Analyzer
  • Integration with the ADO record set XML Function
  • New security, buffering, isolation, and management functions

Reference

Important changes in ASP)
Information: new functions in ASP and IIS 5.0 (q222487)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.