Twitter Updates

Wednesday, April 08, 2009

Moving from MVC Beta to MVC 1.0

During this sprint, one of our clients upgraded from the MVC Beta to MVC 1.0 and I wanted to share what Joe wikied into the team wiki because it might be useful to the rest of us. :)

To upgrade to 1.0 release, you will need to uninstall ASP.NET MVC BETA. You can do this by going to "Add/Remove Programs" under "Control Panel" and find MVC Beta and remove it. Once you have done that, you can download ASP.NET MVC 1.0 from this link.
Once the install is done, do a get latest from TFS.
You can find the Release Notes from ASP.NET team:

There are some changes in 1.0 release compared to the BETA version we have been using up until 3/31/2009. Begining April 1st, all of our ASP.NET MVC project in TFS will be based on 1.0 release. Here are some of the highlights of the upgrade:

  • Views no longer need code-behind by default
  • Visual Studio experience improvements:
    • New contextual commands like "Add Controller", "Add View", etc
    • Able to create partial view (ascx) as a view using the new contextual command
    • Basic scaffolding for strongly type views (list, edit, etc)
    • Ability to add custom scaffolding templates
  • Page title is now setable in the ViewPage instead of just in Master.Page
  • Strongly typed HTML (AJAX) Helper
  • Smarter and less verbose binding for POST forms, including with complex objects
  • CSRF Protection
  • New file handling methods (for upload/download files)
  • Updated jQuery lib to 1.3.2

You can read a more detailed overview in ScottGu's blog here.

For our site(s), I had to manually do certain several things:

  • Remove all the code behinds and update the ascxs and aspxs to bind correctly
  • Update our jQuery references
  • Change HTML helper call to DropDownList since the upgrade changed the API parameters
  • Change all <"button"> to <%=Html.Button ... %> since behaves like if button type is not specified correctly
  • Change every UpdateModel method call to "TryUpdateModel" to utilize non-exception invalid data handling and modify our controllers to display error message correctly
  • Add CSRF validation attribute to all POST action methods in all of our controllers
  • Add CSRF tag within all of our forms to work with CSRF attributes in our controllers
  • Change Delete action method to POST instead of GET to enhance security