Explain the Model, View and Controller
ASP.NET MVC has three main group of components Model, View and Controller, Each one has his own responsibilities as below.
- Model - It contains the business logic and represents the state of an application. It also performs the operation on the data and encapsulates the logic to persist an application state. Strongly-typed Views use View-Model pattern to display the data in the view.
- View - It's responsible to present the content via User interface. It does not contain much logic and use Razor View Engine to embed .NET code into view. If you need to perform much logic to display the data then prefer to use View Component, View Model or View Template for simplify view.
- Controller - It's responsible to handle user interactions, It works with model and select the view to display. Controller is the main entry point that decides the model with which it works and decide which view it needs to display. Hence it's name - Controller means controls user inputs and interactions.
Comments
Post a Comment