N
N
Nik Faraday2021-09-09 13:28:52
ASP.NET
Nik Faraday, 2021-09-09 13:28:52

How to create proper hierarchy in asp.NET Core MVC?

Hello

I started to study asp.NET Core and now I am "stretching" the Bootstrap template and I don't know how to make the file hierarchy correctly.
According to the idea, there is an MVC architectural pattern for everything to be done according to daddies.

In the template, all .html pages are thrown on top of each other and there is no clear hierarchy, by what principle should the same files be thrown as part of an MVC project?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
V Sh., 2021-09-09
@NikFaraday

If I'm not confusing anything, then when you create a project using a template, you already have a marked up hierarchy. There is a "Scripts" folder for scripts, a "Content" folder for storing styles. MVC is not about where and how to store files. MVC is about the fact that you store all objects and classes separately (by default, the "Models" folder), what you want to show the user you also write separately in the View, and how the View interacts with your classes (logic) you already prescribe in the controllers (Controllers).

V
Vasily Bannikov, 2021-09-09
@vabka

There is no single approach, so I'll tell you how I do it (but not in MVC projects)
. We put all the business logic into a separate project.
In this project, in a separate folder there is a data access layer, and in another folder there are all sorts of business services so that the services that belong to the same general area are closer to each other.
In the aspnet project, I already build the hierarchy from the request paths.
That is, if I have a GET /api/v1/orders endpoint, then it will be in the api/v1/ folder.
In MVC it ​​will be similar, only more razor files will be added and it is
better to keep css css next to the templates in which they are used

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question