Top 5 reasons for using ASP.NET MVC 2 rather than ASP.NET MVC 1
I've been using ASP.NET MVC 1 for a while now, and am keen to take advantage of the improvements in MVC 2. Things like validation seem greatly improved, and strongly-typed HTML helper methods look great.
So, for those of you who have real-world practical experience of using ASP.NET MV开发者_C百科C 1 and are now using MVC 2, what are your top 5 reasons for using MVC 2?
- TemplatedHelpers EditorFor, DisplayFor
- ViewPage changes with ModelMetadata and ViewData.TemplateInfo as properties accessibile in the View.
- MVC Areas + MVCContrib Portable Areas
- ModelBinding changes result in more secure MVC apps for free.
- DataAnnotationsModelBinder is a huge timesaver for validating CRUD forms.
EDIT: The question underwent a complete 180 (an instance of the Obama problem) after my answer was written. Upgrading to the 2.0 release of a product seems like a no-brainer to me. The other question was actually more interesting.
I wouldn't unless your app is nearly complete and you don't anticipate new development soon. The number of breaking changes between MVC1 and MVC2 is pretty minimal and you can still use the MVC1 constructs while incorporating new MVC2 constructs in new development. I'm in the process of updating a reasonably large app (50K+ lines of code) from MVC1 to MVC2, and even accounting for the dumb things I did (like not using view-specific models and directly interacting with the ValueProvider) when writing the app as I was learning MVC1, it took me only a few days to make the switch.
So here is my list:
- I'm releasing in the next week or so.
- The app is complete and I'm not doing any more development.
- Areas
- New HTML helpers
- Much better Model support (
Html.TextBoxFor<T>()
) - 2 > 1
- Easy conversion
精彩评论