Home > ASP.NET MVC > ASP.NET MVC View Model Patterns

ASP.NET MVC View Model Patterns


In ASP NET MVC There are three basic concept essential to know is Model ,View,Controller.

  • Model:It  Represent  data in application , you can implement validation , business logic over here.
  • Controller: It handle input data from client or user, modifies data in you application , generate view , call view , you can say it manage overall flow in the application .
  • View: it represent visual representation in you application , this is simply a page you see in browse

Now there is a need of passing data from controller to View , for this purpose you can use View Data dictionary, strongly typed process of passing data .but both mechanism have some limitation. With View Data you can pass data in small amount , even you pass complex data using this but this is not suitable for this purpose.Using strongly typed process of passing data view can represent only one domain or class . Now if you want displaying data from multiple domain in single view then you have to modify the domain again that is not the best practice to do that’s  where  View Model is useful.

ViewModel is not really a new pattern. You may have also heard of a Data Transfer Object or DTO. The idea of a DTO object’s purpose in life is to shuttle data from one layer to another. Think of this as a contract between two layers. As long as the contract doesn’t need to
change, code in a specific layer can be refactored all day long with limited ripple effect throughout your code.

I hope this will be helpful for you in understanding the ViewModel concept . if there are any missing or wrong concept in it then your feedback is welcome.

Thanks for reading this article , and yes , be tuned for new article on MVC, ENTITY FRAMWORK ,WCF.

Advertisements
Categories: ASP.NET MVC Tags:
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: