Friday, 8 July 2016

Upgrading from ASP.NET MVC 3 + Web API RC to ASP.NET MVC 4 to Web API RTM

ASP.NET MVC 4 and Web API are finally released! On to upgrading my projects to the latest version.

I followed the instructions at Upgrading an ASP.NET MVC 3 Project to ASP.NET MVC 4to convert ASP.NET MVC 3 to MVC 4. However, I've got lots of errors. It looks like Microsoft added DisplayNameExtensions.DisplayNameFor, thus conflicting with my own DisplayNameFor extension that does the same thing. LabelExtensions.LabelFor(this HtmlHelper html, Expression> expression, object htmlAttributes) is added too!

 Also, false (boolean) and null (string) now acquired special meanings when used as values in HTML attributes. They are used in Conditional Attributes. False and null thus do not output any attribute. Previously, false gets rendered as the string "False" but now it's gone! My model validator thus complains that the attribute value is not provided. To restore the old behaviour, just do a boolean.ToString().

Using NuGet, I upgraded from Web API RC to Web API RTM. However, for me, my project won't compile. QueryableAttribute is missing! Turns out that I've to add the new package Microsoft.AspNet.WebApi.OData to get the attribute back. Being a little risk adverse because the package is in alpha, I chose to remove all references to QueryableAttribute instead.

No comments:

Post a Comment