Advantage of the ASP.Net MVC framework, Disadvantages of the...

The virtue of the ASP.Net MVC framework

• allows you to fully control the formation of a response to the user and create a clean HTML code of a small size;

• The best divides the presentation layer and the level of business logic;

• allows you to perform unit testing and use the Test Driven Development (TDD) approach;

• Supports various view systems (View Engines);

• Easily integrates with JavaScript libraries (for example, jQuery).

Disadvantages of the ASP.Net MVC framework

• It is not event-based, so it can be quite difficult for developers to master, they are used to thinking in the style of Widows-forms and Web Forms;

• It takes more time to start productive work and more time to learn new things in web development.

Explanation The ASP.Nct MVC frame will be executed using the example of a very simple MVC bookstore application [5]. It will allow you to view the list of books and place an order for their purchase. For the convenience of explaining the ASP.Net framework, first consider creating Models, then Controllers and finally Views.

Creating MVC Web Application Projects

To create an ASP.Net MVC project, use the Microsoft Visual Studio integrated development environment to run the command: File => NewProject => ASP.NET MVC 4 WebApplication (or the older version of the MVC framework). As a result of this command, the dialog box shown in Fig. 4.25.

Dialog for selecting the project template for the ICC application

Fig. 4.25. Dialog box for selecting the project template for the ICC application

When using the Empty template, an empty project is created, which does not include any classes; The Basic template also creates an empty project, but it includes a simple master page and a CSS file; The Inertnet Application template creates a project with classes that support forms-based authentication; and the Intranet Application template creates a project with classes that support Windows authentication.

Structure of the MVC project in Solution Explorer when using the Basic template

Fig. 4.26. Structure of the project MWS in Solution Explorer when using the Basic template

Table 4.10

MVC Project Folder Structure

Folder

Assignment

/Controllers

Storing descriptions of Controllers that respond to browser requests

/Views

Storing descriptions for Views that contain user interface templates

/Models

Storing classes related to the model that perform the data processing.

/Content

Storage of additional files: images, CSS, etc.

/Scripts

Storing files with JavaScript scripts

/AppData

Storage of all necessary files and resources, for example, databases used by the application

In this dialog box, you can also select the visualization tool. ASP.Net has built in two rendering systems, ASPX and Razor, which perform the transformation of the presentation template into HTML code (in more detail in Section 4.2.4).

After clicking OK, Visual Studio will create the project framework according to the selected template. For example, if you select a Basic template, you will create a project with the folder structure shown in Fig. 4.26.

The names of project folders, class names, and their placement are in accordance with the MVC's agreement on project configuration. For example, in accordance with this agreement: the project includes the folders described in Table. 4.10.

Compliance with the project configuration agreement reduces the number of required code and makes it easier for other developers to understand the code of the created project. The details of this agreement will be explained in the course of the description of the ASP.Net MVC framework.

In order to develop the MVC application example, you need to create a project using the Basic template and name it Bookstore.

Also We Can Offer!

Ошибка в функции вывода объектов.