In the past, we mainly used WebFrom development and did not have a deep understanding of MVC development. Since the arrival of the new team in the innovation workshop, the technologies used have never been used before. For example, MVC and EF are also called WCF, which has been under great pressure. When many questions are unclear, ask the people around you, and others just give yourself a rough idea. In addition, I asked a relatively detailed question two days ago and was hit by a sentence from someone else. "I can only tell you the method. You still want to give it to you by hand. You don't have to learn it yourself ...". There is no way to find some materials to learn. After a preliminary understanding of MVC, I found that many people are very confused about the concept of MVC and L3 architecture development. So I will sort out the study notes for the past two days and share them with my classmates. At the same time, I also made a small Demo, so that those who have no experience with MVC development can have a simple understanding of MVC. I. Differences between MVC and L3 architecture ① what is a l3 architecture? When talking about MVC with classmates or teachers at school, others may say, "No, it's a three-tier architecture! The entity layer (Model) is used to create objects. The business logic layer (BLL) is used to process complex relationships between data or between businesses. The database access layer (DAL) is used to create objects ), it is used to access the database. Of course, there will be a View (View layer) that is used to display data. "Although I know this is not the case, I only know a little about it and cannot explain it clearly, that's all. (For details about the operation relationship between the three-tier architecture, refer to my previous blog [ASP. NET development]. NET three-tier architecture simple analysis ). The relationships between them are basically as follows: I still remember that when I was looking for an internship in Zhengzhou during the summer vacation, I was asked about the concept of an n-layer architecture, nima never heard of it! However, according to the query information, the so-called n architecture refers to the business logic layer (BLL) or database access layer (DAL) based on the system requirements) then it is abstracted into several layers (specifically, it is abstracted into classes) to facilitate logical processing and maintenance of code modules. The basic principle is based on a three-tier architecture. ② What is MVC? MVC is actually a pattern of software architecture, which we often call the design pattern. The module consists of three modules: Model, View, and Controller) and View are completely different from models and views in a three-tier architecture. 1) The Model in MVC refers to the data Model used to encapsulate data related to the application's business logic, in addition, you can encapsulate data processing methods (equivalent to business logic ). This is completely different from the Model layer of the three-tier architecture. Model features in MVC: ① has the right to access data directly, for example, database access; ② Model "does not rely on" View) and Controller, that is, the Model does not care about how it is displayed or operated; ③ Model) data changes are usually "published" through a refresh mechanism. ④ to implement the "mechanism" in ③, views used to monitor this model must be registered on this model in advance. As a result, the view can understand the changes in the data model. 2) View: the View here is basically the same as the View on the third layer. It is used to display data and there is no program logic. To refresh data in a View, the View needs to access the Model it monitors. Therefore, you should register the data it monitors in advance. 3) Controller, which does not exist in Layer 3. It mainly serves as an organizational unit at different levels and is used to control application processes. Mainly deal with events and make appropriate responses. "Events" mainly include user behavior and data changes. The above is about the conceptual differences between the three-tier architecture and MVC. Ii. Differences between the WebForm website and the MVC website operating mechanism ① for example, we want to visit a WebForm Website: www.google.com.hk/Default.aspx (just an example ). What actions have our browsers and servers taken? 1) First, the browser sends a request message to the target server. All those who have configured IIS know that the website is mounted on the server and we access the website by accessing the virtual directory. At this time, the IIS of the target host receives the Default access to the virtual directory. aspx file requests. (Of course, this is also a very complicated process, including requesting the DNS server, finding the target host IP address, and accessing the target host based on the IP address. The complex network process is not described. If you are interested, find your own materials for learning.) 2) after the IIS software on the server receives the request, submit the request to the server. NET FramWork for processing; 3 ). NET FramWork will create the Default_aspx class object, which is what we call the Page Object. (After the WebFrom website is created and compiled, Default. aspx will be compiled into the Default_aspx class) The entire process is still Http requests. The internal mechanism of IIS will implement an IHttphandler interface, this interface implements a ProcessRequestfang method. MSDN explains that the ProcessRequest () method calls the Page_Load () method 1 protected void Page_Load (object sender, EventArgs e) of the corresponding page) 2 {3 // the business logic to be processed or the code to access the database 4 // Html or other content to be output 5}