Use MS. Net to develop L3 applications

Source: Internet
Author: User
Traditional two-layer structure

In the past, the client/server architecture has been widely used in application system development. The application logic is usually distributed at both ends of the client and the server. The client sends a data resource access request and the server returns the result to the client. However, the Client/Server structure has many architecture problems. For example, when the number of clients surge, the server performance will be greatly degraded due to heavy load. Once the application requirements change, both the client and server applications need to be modified, causing great inconvenience to application maintenance and upgrade. A large amount of data transmission increases the network load.

  Introduction to layer-3 Structure

The layer-3 architecture adds an "intermediate layer" between the client and the database, also known as the component layer. The layer-3 system mentioned here does not refer to the layer-3 physical architecture, instead of simply placing three machines as the layer-3 architecture, or not just B/S applications as the layer-3 architecture, layer 3 refers to the logic layer 3, even if these three layers are placed on one machine.

Applications in the layer-3 system put business rules, data access, and legality verification into the middle layer for processing. Normally, the client does not directly interact with the database, but establishes a connection with the middle layer through COM/DCOM communication, and then interacts with the database through the middle layer.

Asp.net is only part of. net. In addition to fast compilation and execution, I think the biggest advantage is the writing method of page and code separation (the effect is the same as the Form Design Interface in Delphi and the process code separation ), it is a good news for those of us who are used to RAD tools. In addition, the various Web controls provided by the. Net Library to support events are a revolution compared with the previous webpage writing methods. With the maturity of distributed object technology, the multi-layer distributed application architecture has been applied more and more. Only by changing the application system to multi-layer distributed architecture can the Client/Server structure be solved. In a multi-layer architecture, applications can be distributed across different system platforms, and objects on heterogeneous platforms can communicate with each other through distributed technology. The application system is integrated into a distributed system, which can greatly improve the scalability of the system.

In a multi-layer distributed application, a layer or multi-layer application service program is added between the client and the server. This program is called "Application Server ". Developers can place the business logic of an application on the application server in the middle layer and separate the business logic of the application from the user interface. Provides a simple interface while ensuring the client functions. This means that if you need to modify the application code, you only need to modify the intermediate application server, instead of modifying thousands of client applications. This allows developers to focus on the analysis, design, and development of the core business logic of the application system, simplifying the development, update, and upgrade of the application system.

  Microsoft. NET prepares for the layer-3 Structure

Microsoft. NET Framework is a next-generation development platform launched by Microsoft .. Net is a public platform class library (FCL) based on developers. It contains nearly 100 classes of nearly 5000 namespaces, think about how powerful it is, including a Common Language Runtime Library (CLR ). Because as long. net (CLS languages can all use the powerful classes it provides and compile them into Microsoft's intermediate language (msil ), it can be called as a component in other applications. At the same time, you can enjoy all the benefits of public runtime libraries: Garbage Collection (GC), real-time compilation (JIT), cross-language interaction, and cross-platform. . Net can also be used as an image-oriented API provided by the operating system to developers. Asp.net is part of. net. In addition to the fast compilation and execution speed, I think the biggest advantage is the writing method for separating pages from code.. Net Library provides various Web controls that support events, as well. net public platform class library (FCL), compared with the previous method of writing web pages, is a revolution.

  Deploy a three-tier architecture with ASP. NET

ASP. NET can use the. NET platform to quickly and conveniently deploy a three-tier architecture. The revolutionary change in ASP. NET is that event-based processing is also used on the webpage. You can specify the background code file to be processed, and C #, VB, and J # can be used as the background code language .. Net, and the backend code can conveniently use custom components through naming controls. The display layer is placed on the ASP page, and the database operations and logic layers are implemented by components, which facilitates the implementation of the three-layer architecture.

The following is a small example of creating a message book for the implementation of each layer.

First, create a database gestdb in the sqlserver database and create a table in gestdb: Guestbook


       Create table Geustbook(id int(4) unique not null,name varchar(20),    content text, Primary key id);

Step 1: Open. net, click File-New-blank solution, select visal C # project in the pop-up new project, and select ASP as the template.. NET web applications. name this solution geustbook at the location. as shown in.

Step 2: Create a database access control. Click "OK ". In Solution Explorer on the right of the window, right-click solution Guestbook and choose add.-> new project. In the following window, select a class library as the template, enter the name and location. Note that this class library theoretically has nothing to do with the message book project, so the storage location can be arbitrary.

Step 3: Create a logic processing layer. In step 2, create another control businesslayer. This control is used to call database controls and encapsulate all logic processing in the message book. As shown in.

Step 4: reference. Because businesslayer uses the web control of the system and the dblayer just created, you must add references to the two. Right-click businesslayer's "Reference" and select. Net's "system. Web. dll" double-click to select

Click "dblayer" of the project and double-click it.

Step 5: Associate the guestbook ASP. Net project with the logic layer and add reference as well. Note: dblayer has been referenced in businesslayer. You only need to reference businesslayer in guestbook.

Now your guestbook solution resource manager should be shown in:

If not, check the steps above for errors.

Through the above steps, the three-tier architecture of ASP. NET has been successfully deployed. At the guestbook layer, we place the ASP page displayed by the application. At the businesslayer layer, we implement all the business logic code at this layer. The datalayer layer mainly processes database operations for the businesslayer to call.

As long as you implement a specific class in each layer, you can successfully implement a three-tier application.

Summary:

This article briefly describes the three-tier architecture software system idea, through an example of a message book mainly introduces the specific implementation method of deploying the three-tier structure with ms. net.

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.