As I'm sure you are all aware that the guys have released Preview 5 of
ASP.NET MVC Framework.
This preview has had a lot of changes since preview 4 and this means a lot of changes to get a preview 4 application building (and running correctly) against preview 5.
I have managed to get my application running (eventually!). Here are the main areas that I had to change to get it working:
New dlls
Almost goes with out saying but you need to reference the new set of dlls
- System.Web.Mvc
- System.Web.Abstractions
- System.Web.Routing
- Microsoft.Web.Mvc
Web.config change
System.Web.Abstractions and
System.Web.Routing are now at version 3.5.0.0; therefore you must update all references in the
web.config from
Version=0.0.0.0 to
Version=3.5.0.0
No More BindingHelperExtensions.UpdateFrom() Method
Preview 5 now contains Model Binding, which is a lot more powerful way of binding data to your models. A great post on this can be found here:
http://www.singingeels.com/Articles/Model_Binders_in_ASPNET_MVC.aspx
To replace the simple
BindingHelperExtensions.UpdateFrom() Method you can use the following:
//Old method in preview 4
//BindingHelperExtensions.UpdateFrom(dto, Request.Form);
//New method in preview 5
UpdateModel(dto, Request.Form.AllKeys);
this.ReadFromRequest() has also gone.
The
HttpRequestBase allows you to simply pass the key you want:
query = Request["query"];
LinkBuilder has moved to "Futures"
If you ever used the
LinkBuilder in your code; this can now be found in
Microsoft.Web.Mvc
No more HttpContextWrapper2
In Preview 4 Microsoft had the very well named
HttpContextWrapper2. In Preview 5 this has gone, and you should be able to just use the better named
HttpContextWrapper.
Html.RouteLink() has new overloads
This is where you will need to check your application thoroughly for any unusual links in your pages.
In Preview 4
Html.RouteLink() Extension took three parameters:
- string linkText
- string routeName
- RouteValueDictionary values
In Preview 5 the three parameters have change to be:
- string linkText
- string routeName
- object htmlAttributes
Because
RouteValueDictionary is an
object, your routes dictionary now gets treated as if you wanted to add then as attributes on the link element!
Now I have to add null (for the
htmlAttributes) as a forth parameter like so:
<%= Html.RouteLink("Click Here", "Deafult", new { controller="Home", action = "Index"}, null)%>
Build MvcContrib
My application uses the MvcContrib. Right now not all test pass and therefore there is not a official release on the MvcContrib for Preview 5. However, the project is building and you can download the source from here:
http://mvccontrib.googlecode.com/svn/branches/Preview5
Is that everything?
I managed to get my application working with the above changes, however there were sections of code for my admin section that uses it's own
ViewLocator that I had to comment out to build. I have not quite figured out the new changes to the
ControllerBase and
IController....watch this space.
Hope your
ASP.NET MVC Preview 5 application works sucessfully!