Asp.net MVC 4 Study Notes (1)

Source: Internet
Author: User
Tags what is asp

The latest product of the company has been changed to the MVC development model. Previously, product development was a classic three-tier architecture. For programmers who "hear" but have not actually "compensated" MVC, It is a narrow expression of knowledge. As a result, I recently studied Asp.net MVC. At the same time, record your study notes for future reference. Some content may come from the Internet or others' blogs. If there is any infringement, please contact for modification or explanation. I. What is the difference between the three-tier architecture and the MVC product from the three-tier architecture to the MVC Architecture? It seems like a long discussion! What is a three-tier architecture: Generally, the three-tier architecture divides the entire business application into: presentation layer (UI), business logic layer (BLL), and data access layer (DAL ). The purpose of hierarchy differentiation is the idea of "high cohesion and low coupling. 1. Presentation layer (UI): The interface displayed to the user, that is, what the user sees when using a system. 2. Business logic layer (BLL): the UI Layer casts data to the BLL layer, and The BLL layer processes the data business logic. 3. Data access layer (DAL): accepts BLL data. transactions made at this layer directly operate on the database, and add, delete, modify, and query data. What is ASP. net mvc: M (Model layer), mainly responsible for business logic and database interaction V (View layer ), it is mainly used to display data and submit data. C is the Controller. It is mainly used to capture requests and control the connection and difference between the three-tier architecture of request forwarding and MVC: Through comparison between the two, the three-tier architecture does not have the Controller concept, which is the main difference between the two. At the same time, both of them have a Model layer. Although they share the same name, the concept of Model in the three-tier architecture is different from that in MVC, in Layer 3, a typical Model layer is composed of entity classes, while in MVC, it is composed of business logic and access data. They share the same design philosophy: separating View Design from data persistence to reduce coupling, ease of expansion, and improve team development efficiency. Their "difference" is that the three layers are divided based on business logic, while the three layers of MVC Based on pages are a software architecture that implements programming through interfaces, the MVC mode is a composite design mode. The three-tier solution mode is the architecture mode. MVC is the three-tier design mode and can be attributed to the deployment mode. The MVC mode can be attributed to the presentation mode. Note: the association between the layer-3 architecture and MVC is obtained based on others' blogs to enhance your understanding. For details, visit: differences between layer-3 architecture and MVC 2. Start the MVC journey to create an MVC project: Click OK. In the displayed dialog box, select a template with a red frame. After the creation is successful, you will find that there are many folders in the solution. The general files and descriptions are as follows: generate the solution for the project and start executing (not debugging) we will find that the solution to my first MVC project is actually like this. Amazing ~, Do not understand? It does not matter. This is only a basic Demo provided by Microsoft. Open the file and you will find it very simple. You can understand it at a glance. Of course, VS2012 comes with a tool that can preview webpage effects-Page Inspector. Just like the functions provided by MyEclipse in Java, it is simple, convenient, and powerful. When debugging a page for a layer-3 architecture project, we often need to enter the website address, and the suffix of the website will contain an index. aspx, but does the MVC website seem to open a file directory? Without a specific page, do you always feel that something is missing? The MVC working mode is actually like this: (Note: image reference @ lulu Studio) Some people think that the address is not a specific page (such as index. aspx), but is the last index page displayed? This is because the URL has been rewritten !. In ASP. NET, it is called UrlRouting and the corresponding assembly is System. Web. Routing. It is a route, you know. 3. Analyze the first Demo. Use the first Demo created in VS2012 to open VS2012 and create a project according to the above method. These files will be generated, will be deleted in actual development ]. Open index. on the cshtml page, we will find the following code [see the yellow shading section]: Copy code 1 @ {2 ViewBag. title = "Homepage "; 3} 4 @ section featured {5 <section class = "featured"> 6 <div class = "content-wrapper"> 7

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.