What should Model do in MVC?

What should Model do in MVC?

The MVC pattern, in a nutshell, is this:

  • The model represents the data, and does nothing else.
  • The view displays the model data, and sends user actions (e.g. button clicks) to the controller.
  • The controller provides model data to the view, and interprets user actions such as button clicks.

What should a controller class do?

Controller . Controller class contains public methods called Action methods. Controller and its action method handles incoming browser requests, retrieves necessary model data and returns appropriate responses. In ASP.NET MVC, every controller class name must end with a word “Controller”.

What does a controller do in code?

Controller: Controller code acts as a liaison between the Model and the View, receiving user input and deciding what to do with it. It’s the brains of the application, and ties together the model and the view.

What should the controller or the model do?

Controller – bridge between the model and view. Decides where to go next. Model – business logic, interface to data store. One of the biggest gains is in maintenance and (later) expansion. In general: If you need to change business logic, you should not need to modify your controller or view.

Do you call getCustomer from the controller or the model?

If you are writing any Linq code in your controllers, you are creating a dependency that will have to be modified if your site structure changes, and you are potentially duplicating data access code. But GetCustomer in the model is still GetCustomer, no matter where you’re calling it from your Controllers. Does that make sense?

Where do I find models views and controllers?

You will see several folders and files in the Solution Explorer window. In particular, you’ll see three folders named Models, Views, and Controllers. As you might guess from the folder names, these folders contain the files for implementing models, views, and controllers.

Which is model should a model handle validation?

So the actual validation, as in “is the data well formed?”, should be performed by the controller. However the verification, as in “does the data make sense?”