Archive for the ‘MVC’ category

Migrating an MVC1 app to MVC2

May 2, 2010

I ran through this process on the Activate Your Glutes website yesterday and thanks to Eilon Lipton’s migration tool its fairly painless.

That said I did come across a couple of gotcha’s that are worth documenting:

1) I’m using jqGrid with an ajax call back to the server to pick up some JSON data. After undertaking the migration my grids were not being populated even though the actions on the controllers were running correctly. Turns out the reason for this is that JsonResult now, by default, denies when responding to a get request.

This is to prevent JSON hijacking as detailed here. There are two ways of fixing this – configure the ajax call to be a post (which if you’re doing a read is not very rest-ful but needs must) or if the data you are returning is not sensitive then set the JsonRequestBehavior property on your JsonResult to JsonRequestBehavior.AllowGet. I’ve used a mixture of approach depending on the sensitivity of the data.

2) The ValueProvider has been changed in an interface breaking manner. It used to be a dictionary and now, well, it isn’t. If you were doing something exotic this might cause you a problem but if, like me, you were simply getting value’s from it then a call to GetValue() on the ValueProvider will sort you out.

And so far thats all the problems I’ve hit.

Activate Your Glutes and Visual Studio 2010

February 3, 2010

If you’ve downloaded the source code for the site you’ve probably noticed that it’s still using MVC 1.0, Entity Framework 1.0 and Visual Studio 2008.

I’ve been using Visual Studio 2010 and .Net 4 for a few weeks now on a commercial project and, since ReSharper 5.0 was released in beta (losing ReSharper is a painful experience), have found it to be a fairly stable and usable experience though I hope they sort out the performance issues in the IDE by the time it is fully released – I don’t recall ever waiting for my 8-bit BBC Micro with its mighty 6502 processor and 32kb of RAM to catch up with my typing.

But back on topic, I do plan on moving the site over to MVC 2.0 and Entity Framework early next month. I’m particularly keen to see how the much touted Entity Framework improvements work out as version 1.0 is frequently horrible and I keep wishing I’d used NHibernate.

A prerequisite for me doing this however is getting integration tests in place for my repository implementation for which I’m planning on using ndbunit for the first time. If anyone has any experience with this, good or bad, then I’d be interested in hearing any comments you might have and experiences you think are worth sharing.