Friday, December 17, 2010

Rewriting WebForms to MVC

This week we finally started to port our project from ASP.NET WebForms to ASP.NET MVC. We made this decision, because we were so sick of the grief the Infragistics Grid control was causing us. Not only does it output horrific html. Our dynamic data structure also causes us way too much grief with the grid.

The main problem with Infragistics is that the product is so mature that there are half a dozen ways to do any particular thing. Since the documentation is so scant and the community so poor, it's hard to figure out how to actually accomplish what it is you're trying to do. A lot of the time it just feels like you're working inside a glove box and glove box has been spray painted black.


There really doesn't seem to be a method to solve a particular issue, just a lot of fiddling. Setting a property to this, handle this event, call this method on the column, etc. So this frustration has finally boiled over and we've begun rewriting the app to pull out Infragistics and at the same time move our app to MVC.

I was dreading doing the port. However, so far it has been quite easy. Fortunately for us, when we designed our application, we designed with our own MVC style pattern that sat on top of WebForms. Similar to what they've done over at WebFroms MVP So the code behind was only used for handling the UI. All of the complex business logic was passed on to Controllers. So for the most part it has been a fair amount of copy and paste. We haven't gotten to the grid portion so I may be paying for this early optimism yet, but I have been pleasantly surprised with our progress so far.

Addendum
We had to keep around a couple of server controls that were reports. So we had to find a way to render WebForms as part of an MVC action. Here's how we did it.