tags:

views:

133

answers:

1

Coming from ASP.NET Webform and Classic ASP. I want to know what are the best practices. Are MVC apps would not really be using Server Controls and ViewStates? If so the persisting of the html form controls would be similar to classic ASP. Thanks

+3  A: 

Some of the big ones I learned in my move:

1) Views should have very limited logic. If you find you have lots of <% if(...) { %> statements, you need to add more information to your models and/or create HtmlHelper extension methods that handle that logic.

2) Your controller classes should only interpret user input and request data from your models. If decisions have to be made about the data, the controller should push the information required to make those decisions to the models.

3) The models should keep all your business logic relating to data. Partial classes are your friends here. Lots of DAL generators let you use partials to add logic to your generated models (such as Linq to Sql and Subsonic).

4) State is the enemy. That's not just MVC; I just like pointing out that the more state your design requires, the easier it breaks.

Will