ASP. NET MVC5 website development project framework (2), mvc5 Development Project

Source: Internet
Author: User

ASP. NET MVC5 website development project framework (2), mvc5 Development Project

A few days ago, I started my project and thought a lot about how to do it myself. But after all, I don't know whether these ideas are necessary or not, but Grandpa Deng said, "crossing the river by feeling the stones. During this time, I have read some blogs, especially @ kencery.

I. Basic Framework

Let's talk about the basic framework first. Seven projects are suddenly messy. In my understanding, M is the data carrier among M, V, and C, V is the attempt of the user. C is mainly responsible for coordinating and controlling operations related to the user interface. Data processing and database operations are handed over to DAL and BLL. The entire idea is: View is the interface that the user sees; Controller is responsible for coordinating user operations and looking for the business logic layer when data is needed or processed; when the business logic layer needs to access the database, it finds the data access layer. The data access layer interacts with SQL Server through EF. The data interaction media between layers is Model.

Here, IBLL and IDAL are interfaces and functions are implemented in BLL and DAL. They seem redundant, but they are still very useful. One is that the interface only implements the method definition at a glance; the other is that as long as the interface remains unchanged, no matter how the implemented code is written to the call between projects, it will not change.

2. Project Establishment

1. Create a Web project.

Choose template> Visual C #> Web> ASP. NET Web application.

Here, there is a significant change with vs2012, In a template made by webform, mvc, api, etc.

What if I want to develop it as before? Click web-> Visual Studio 2012.

Choose Web> ASP. NET Web application.

Select MVC here (you can add webform and api references to bring together previous projects. Here, only MVC is selected. for authentication, select an individual user account. This will add the latest ASP. NET Identity usage code (in fact, it doesn't matter what you choose. ASP is not used here. NET Identity. You can choose whether to manage the user or choose to check how Microsoft code is written ).

2. Create 6 Other Projects

Right-click solution> Add> new project

Select project type> Visual C #> Windows> class library.

To create six other projects.

The framework after completion is as follows:

3. References between projects

After a project is created, you must add references between projects.

Right-click a web project reference and choose solution> Add Ninesky. Models, Ninesky. Common, Ninesky. IBLL, and Ninesky. BLL references to the project.

Add Ninesky. Models reference to IDAL in sequence

Add Ninesky. Modles and Ninesky. IDAL references to DAL

Add Ninesky. Modles reference to IBLL

Add Ninesky. Models, Ninesky. IDAL, Ninesky. DAL, and Ninesky. IBLL references to BLL.

In addition, DAL Models must add an EntityFramework reference to Nuget. The method is to right-click the project reference and choose manage NUGET package. In the displayed window, choose online> nuget.org> EntityFramework and click Install to automatically complete the installation.

Now the framework is complete. Here, the web project represents v and c in mvc. The modle project represents m. The common project is ready to write public methods. The other four projects are regarded as the data access layer and business logic layer in the three-tier architecture. In addition, interfaces are used. You can finally write code next time.

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.