Experience in ASP programming: A summary of 10 experiences on ASP development

Source: Internet
Author: User

The application server is, or will eventually be used by, the WEB server, which is typically the IIS computer running the ASP page. ASP is the only client for your object. It brings specialized threading and security considerations.

Although many Web sites that use ASP do not have components at all, this article assumes that ASP is a bridge between Internet clients and components. The following asp/server01242000.asp ">asp component Guidelines (English) provide

Partitioning services between ASP and components

ASP is most commonly used to create HTML or XML files for client use on the server, so we mainly discuss this usage scenario. This leads to a common problem, if the ASP pages are on the server, are they part of the business layer? In the world of components, the answer is usually. Although the ASP does run on the server and may be in the same space as the application server, this does not make it a part of the business logic.

With the development of user interface tools or with the enablement of more business-to-business scenarios, having this clear distinction will yield huge rewards.

In this context, let's look at some of the most important business layer and presentation layer partitioning guidelines:

Separates the UI code from the business logic. This includes writing code that is coupled to the UI, such as a MTS object that uses internal components of ASP, to separate it from the business logic code, as in different DLLs.

Detach the transaction from the ASP page. Transactional ASP is very good in some cases, but components and multi-tier applications can change this situation. Components should not rely on the client layer to manage their transactional and business logic semantics.

Place the component that represents the component (using the request and the response) with the WEB server in the same machine and/or process. If you place an object that uses an ASP internal component object on a remote machine, all calls to the internal component will occur in a callback form. Calling the IIS client is a COM + server that significantly reduces performance and complicates security configuration. You can place these adjustment objects in a COM + application that is labeled Library activation.

ASP exists on the server, so ASP pages must conform to resource sharing rules and remember scalability. Shanghai Male Hospital For more information:

In sessions, management should try to avoid user-specific state.

Keep the ASP stateless and allow the resource pool where possible.

Operation mode

When evaluating whether a piece of code belongs to a business logic or presentation layer, ask yourself, "If I have to replace my ASP page with a touchtone phone application, is that code useful?" If the answer is yes, you can try dividing it into business logic code or user interface helper code.

If the code is not available after the client has changed, or if it is a helper that constructs the user interface, the code belongs to the service layer. It is in an ASP page, or in a component that uses internal components of ASP. It does not belong to the business object component.

Understand the difference between a desktop and an ASP client

ASP is a special client of a component, unlike a traditional single-threaded WIN32 application on the desktop. The main differences are summarized below.

Thread Management: ASP is a multithreaded client. This means that there can be many concurrent activities running together, and perhaps working on different ASP pages at the same time. This means that you cannot make an object pretend that it is the only consumer to monopolize the system. This can be an unexpected reaction, for example, to develop a bad habit of storing objects in an ASP session or application variable.

Secure environment: ASP is performed by Internet Information Services 5.0 in the Web site, with low, medium, and three isolation degrees. Even these Web sites can have different security settings, allow or deny anonymous access, authenticate customers, and so on. All of these settings produce a large number of scenarios in which different user accounts end up with your objects.

Easy growth: This is not a technical issue, but rather a side effect of the facilities provided by the WEB application. Traditionally, adding a user base to a desktop application requires careful planning of the transfer out to a known number of clients. The ASP has changed the process. After starting and running, the Asp-visual Basic application can be easily opened for use by all employees, all business partners, and all customers, locally or worldwide. Can be described in this way-a single e-mail message with a hyperlink can increase the user base by 10 times times. Is your application ready for this? The only way to understand this is to test your Web site for strength to get the expected value of actual performance. For more information about strength testing, see the "Application Lifecycle" section.

How should Visual Basic objects be used within an ASP? Create and cancel your objects within the page range. That is, make the ASP page stateless as much as possible, relying only on session or application variables in a temporary state. Do not store objects in session or application variables. This locks the ASP thread to your session and cancels all the expected values for scalability. In other words, the WEB server does not process more than dozens of users. If you need to store content in a session or application, make it data instead of an object.

There are many other guidelines that you can follow. We recommend that you read the column "Servin ' It Up" written by J. Meier on the MSDN Voices. This column includes a number of techniques, practices, and techniques to help develop scalable, reliable ASP and component applications.

Reference

Asp#server ">msdn Voices:servin ' it Up Column (US)

Seminaronline: Using custom COM Components under ASP (US)

ASP ">MSDN Magazine" do not store references in a VB object in a session or application

All Visual Basic 6.0 components are "unit threads", meaning that they all run in the STA unit. This means that if an object is created in a thread, all calls to that object must be serviced with the same thread. Many threads (from concurrent WEB site users) Use the same instance of the STA object, causing a series of activities that could become bottlenecks in the application.

In addition, storing STA objects created with Server.CreateObject in session scope effectively restricts the execution thread to the current user, limiting the maximum number of concurrent users in the application to the default of 20xN (N = number of processors).

Operation mode

If you follow our recommendations to make the object stateless, you do not need to store references for the client to reuse and store them within the scope of the application. Clients will be able to create, use, and cancel their own objects independently. This reduces the need to maintain session-specific objects because they do not preserve session-specific state.

The recommended approach is to make the object stateless, accessing the database or other storage areas (such as cookies and LDAP) when needed.

If you need to use session or application-scoped data, store the data, not the object that handles the data, in this. You can create a class that encapsulates the processing of the required values.

Reference

ASP > Info: Do not store STA objects in a session or application (Q243543)

PRB: Stores the STA COM component in a session and locks the session to single-threaded approached (Q243815)

Info: Component Threading Model Overview under ASP (Q243544)

Learn what's new in IIS 5.0

Internet Information Server 5.0 adds a number of new features. These improvements have been written to the asp/server02282000.asp of J.D. Meier's MSDN article: "> Inherits from ASP in IIS 5.0. The following is an overview of the most important improvements in this article.

Improved, superior performance

Server.Transfer and Server.Execute methods

Centralized error handling

Improved Browser Capabilities

Improved scripting engine

Regular Expression Parser

Integration with ADO recordset XML functionality

New security, buffering, isolation, and management capabilities

Experience in ASP programming: A summary of 10 experiences on ASP development

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.