What is the layer-3 structure of ASP. NET?

Source: Internet
Author: User
Why n-layer architecture?

Because each layer can only change a small numberCodeIt can be put on different physical servers, so the structure is flexible and the performance is better. In addition, other layers in each layer are completely invisible. Therefore, you no longer need to re-compile or change all layers to modify or update a layer. This is a very powerful function. For example, if you separate the data access code from the business logic layer, after the database server changes, you only need to change the data access code because the business logic layer remains unchanged, therefore, you do not need to change or recompile the business logic layer.

One n-layer applicationProgramThere are usually three layers: presentation layer, business layer, and data layer. Next let's take a look at what each layer does.

Presentation Layer)

The presentation layer is used to display user interfaces and to "Drive" These interfaces using classes and objects in the business layer.

In ASP. NET, this layer includes aspx pages, user control, server control, and some security-related classes and objects.

Business tier)

The business layer is used to access the data layer, fetch, modify, and delete data from the data layer, and return the results to the presentation layer.

In ASP. net. This layer includes using sqlclient or oledb to retrieve, update, and delete data from SQL Server or access database, and placing the obtained data in datareader or dataset and returning it to the presentation layer. The returned data may only have one integer number, for example, the number of row records in a table. However, the data must be calculated at the data layer.

Bll and Dal

This layer is usually divided into two child layers: business logic layer (BLL) and data access layer (DAL ). The business logic layer is above the data access layer, that is, BLL calls the Dal class and object. Dal accesses the data and transfers it to BLL.

In ASP. NET, this layer can use sqlclient or oledb to retrieve data from SQL Server or access database, and send the data to bll in the form of dataset or datareader. BLL processes the data to the presentation layer. Sometimes, for example, BLL is a transparent layer when dataset or datareader is directly sent to the presentation layer.

Data tier)

The data layer is a database or data source. In. net, it is usually an SQL Server or access database, but not limited to these two forms. It may also be Oracle, MySQL, or XML.

Logical layer vs (distributed) Physical Layer

It is easy to confuse these two concepts. We say that the logic layer divides layers by class sets, and these layers are all on the same server. (Distributed) the physical layer refers to the collection of classes on different servers, and additional code is used to process inter-layer communication, such as remoting and Web services.

It is very important to decide how to divide your layer (whether it is physical or not physical. The following factors should be taken into account when dividing:

1. Note that if your application is divided into physical layers, the speed of communication between different servers will slow down due to the delay in network communication. Therefore, if you decide to use the physical layer, ensure that the performance improvement is greater than the performance reduction.

2. design your applications based on the N-layer architecture.

3. The cost of deploying and maintaining physically distributed applications is high. You need more than one server first. You also need network hardware to connect to these servers. In this case, deploying applications becomes more complex! Therefore, before doing so, determine whether it is worthwhile.

note how to use each layer of your application. You may need to place the layer on another server because multiple services run require a certain layer. For example, you may customize different performance layers for different users and place the business logic layer elsewhere. You may also access the same database because of other applications, the SQL Server service is put elsewhere.

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.