Friday, August 17, 2012

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 4 to 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.

Wednesday, August 15, 2012

Windows 8 IndexedDB invalid access error

While following the code at Getting Started with IndexedDB, I encountered the invalid access error at this line
var transaction = db.transaction("people", IDBTransaction.READ_WRITE);

It turns out that the IDBTransaction is obsolete. Following the instruction at IndexedDB changed in IE10 PP6, I changed the code to the following. It now works!
var transaction = db.transaction("people", "readwrite");