Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the breakdown of all of the layers required/recommended for an Asp.Net Mvc Application following best programming practices?

The more I read into Asp.Net MVC the more layers and components I find out are required in order to make my application follow all of the standards and best programming practices.

It's starting to get a bit confusing because some of the new layers don't seem to fit in as easily as the others I learnt. So I just wanted someone to go over all of the required/recommended layers for an Asp.Net MVC application- what purpose they serve and how they interact with the other layers.

Here's a few of the layers I've found and how they link up: (Some of them may be wrong)

View/UI --> Model Binder --> Controller --> Service Layer --> Repository --> Entity Framework/LINQ to SQL --> DB

Could someone go over ones I may be missing, how they all link up, and what each of their purposes are?

Thanks,
Matt

like image 761
Matt Avatar asked Jul 13 '09 20:07

Matt


People also ask

What are the layers in MVC?

It provides three main layers; model, view, and controller. Many developers use MVC as a standard design pattern.

Which of the following is the 3 basic parts of ASP NET MVC framework?

The Model-View-Controller (MVC) architectural pattern separates an application into three main components: the model, the view, and the controller.

What is the correct order for the lifecycle of an ASP.NET MVC page?

MVC actually defined in two life cycles, the application life cycle, and the request life cycle. The Starting point for every MVC application begins with routing. After that, the received request figures out and finds how it should be handled with the help of the URL Routing Module.


1 Answers

Good question, I think you covered all the layers I have seen: Modal binder and service layer are optional.

Maybe, you can add another Error Handling layer such as elmah.

  • View/UI --> You put your html markup / Javascript code.
  • Model Binder --> You perform the magic to bind your input to the action parameters, normally, you will use the default binder, so you don't need worry about it. However, you can override this with your own binder, and do validation in this layer. Here is a good example on this.
  • Controller --> Enough documentation online.
  • Service Layer --> A lot of people do validation and other business logic processing here before sending it to repository. Asp.net mvc contact manger example has a good example here. This is also the layer to actually work with your modal.
  • Repository --> Simple read/write operation.
  • Entity Framework/LINQ to SQL --> DB - Actually writing to database. Nhibernate is another good candidate here.
like image 66
J.W. Avatar answered Oct 20 '22 01:10

J.W.