Geeks With Blogs
David Williams Who's scruffy looking?

At a high level, this is how I understand the different MVC tiers:

  • Model: Data libraries such as entities, Linq to SQL classes, or any other data library.
  • View: The .aspx/.ascx pages.  The classic ASP style code goes here.  I have heard this layer referred to as a ‘report’ where you have as little logic as possible, and only that related to the display of the page. 
  • Controller:  If you are coming from ‘standard’ ASP.Net and are new to MVC, You could say the controller is what replaces the code behind.  However the controller is very different.  Think of a controller as code that packages data to send to View.  It has no events, no viewstate, but a series of actions or methods that return data to the View.
  • “View Model”:  Think of a ViewModel as having only the data that is needed by the View.  Typically the controller takes data from (for example) one or more Models, and places it in the ViewModel.  Not all data from the Model makes it into the view, and the controller can add additional info not in the Model. 
Posted on Thursday, October 14, 2010 9:46 PM | Back to top


Comments on this post: MVC tiers

# re: MVC tiers
Requesting Gravatar...
I think this is very accurate. The only addition I have, and I'm sure you already know this, is that business logic only ever belongs in the Model, never the Controller. I just wanted to make sure that's stated here.
Left by Ryan on Oct 15, 2010 1:59 AM

Your comment:
 (will show your gravatar)


Copyright © David Williams | Powered by: GeeksWithBlogs.net