I have developed in the past always classic ASP.NET solution. I am starting currently to develop ASP.NET MVC solutions, but i have a problem understanding what a Model is and what it should contain.
In the past i had an Object. For example one for
Product and an object for
Countries and one for
Product Categories. Then within the class
User i had a methods for retrieving a user, saving and updating it. The User objects properties where bound to Textboxes or labels on the .aspx page through codebehind code. Then the DropDowns for Country selection and the DropDown for Product Categories was also bound through the corresbonding objects.
Now my question on the M > Model in ASP.NET MVC. What should it contain and what not? I mean the Model as my understanding needs to hold ALL information which are needed to render the page. Does this means that i will have a
List<Countries> for the DropDown boxes and also
User.CountryId both in within the Model? And even the ErrorMessage needs to be added to the Model when i throw an exception and want to show it on the same page? Or am i wrong? What is the difference between
ViewBag? When to use what? Questions over questions but maybe someone can enlighten me :)