---
title: "What is ViewModel in MVC?"  
description: "What is ViewModel in MVC?"  
author: "Austin Luthar"  
published: 2022-11-23  
updated: 2023-06-04  
canonical: https://www.mindstick.com/forum/157215/what-is-viewmodel-in-mvc  
category: "asp.net mvc"  
tags: ["mvc"]  
reading_time: 2 minutes  

---

# What is ViewModel in MVC?



## Replies

### Reply by Aryan Kumar

A view model is a class that is used to [transfer data](https://www.mindstick.com/forum/34257/how-can-transfer-data-from-one-activity-to-another-activity-in-android) between the controller and the view in an [MVC application](https://www.mindstick.com/forum/12932/how-to-consume-webservices-from-asp-dot-net-mvc-application). It is a lightweight class that contains only the data that is needed by the view. This makes it easier to work with and reduces the amount of data that needs to be transferred between the controller and the view.

ViewModels are used to improve the separation of concerns in an MVC application. The controller is responsible for getting data from the model and passing it to the view model. The view model is responsible for formatting the data in a way that is easy for the view to use. The view is responsible for displaying the data to the user.

ViewModels can also be used to add validation to the data that is entered by the user. The view model can have properties that have [validation rules](https://www.mindstick.com/forum/158293/is-it-possible-to-create-custom-validation-rules-using-jquery-validation-if-so-how) associated with them. When the user enters data into the view, the view model can [check the data](https://www.mindstick.com/forum/161517/how-do-you-check-the-data-type-of-a-variable) to make sure that it meets the validation rules. If the data does not meet the validation rules, the view can display an [error message](https://www.mindstick.com/forum/23174/error-message-the-page-you-are-requesting-cannot-be-served-because-of-the-extension-configuration) to the user.

ViewModels are a powerful tool that can be used to [improve the performance](https://www.mindstick.com/forum/157912/what-is-regularization-how-can-it-be-used-to-improve-the-performance-of-a-machine-learning-model), maintainability, and scalability of [MVC applications](https://www.mindstick.com/forum/158596/what-are-the-best-practices-for-testing-and-debugging-asp-dot-net-mvc-applications).

Here are some of the benefits of using view models:

- **Improved separation of concerns:** View models improve the separation of concerns in an MVC application by separating the data from the presentation. This makes it easier to maintain the application and makes it easier to test the different components of the application.
- **Reduced data transfer:** View models reduce the amount of data that needs to be transferred between the controller and the view. This can improve the performance of the application by reducing the amount of network traffic.
- **Improved validation:** View models can be used to add validation to the data that is entered by the user. This can help to prevent errors and improve the [user experience](https://www.mindstick.com/articles/12731/the-importance-of-feedback-to-the-user-experience).
- **Improved testability:** View models can be easily unit tested, which can help to [improve the quality](https://answers.mindstick.com/qa/93675/8-tips-to-improve-the-quality-of-real-estate-videos) of the application.

If you are developing an MVC application, I recommend that you use view models to improve the performance, maintainability, and scalability of [your application](https://www.mindstick.com/forum/34702/please-tell-me-what-is-cross-site-scripting-and-how-is-it-harmful-for-your-application).


---

Original Source: https://www.mindstick.com/forum/157215/what-is-viewmodel-in-mvc

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
