I have been looking for an open source alternative to the default way of buildig web sites in ASP.NET with Visual Studio. After having build a couple of applications with Ruby on Rails it hard to go back to the Page Controller pattern that Microsoft introduced in ASP.NET. Coming back to the ASP.NET page event model makes it clear that they created it for VB6 application developers that were used to Windows forms-centered development. Apparently they didn’t want to those developers to have to learn about HTTP and HTML to be able to write applications.
I guess from a marketing persepective it may have been the right choice (for Microsoft), but right now it feels like a horrible mess for me. So, I spent a couple of hours researching the alternatives. There are a number of commercial packages available (LLBLGen et al) but I only found three that looked interesting for my purposes:
- MonoRail: The Ruby on Rails-inspired framework with an ActiveRecord component based on NHibernate.
- Spring.NET: A port of the Spring framework for Java.
- PixelDragons MVC: this looks promising but seems to lack real world use? Requires further investigation.
Looking at the quickstart documentation for Spring.NET I decided that it was way too much configuration involved to get things running. Ruby on Rails has definitely lowered my tolerance for lengthy project setups.
The getting started tutorial for MonoRail looked much more pleasant. The MonoRail framework comes with a nice MSI installer and a custom project wizard to quickly set up a project skeleton in Visual Studio 2005. There is even an option to create an associated test project from the start.
After some initial problems with getting the application talking to my SQL Server 2005 database (Microsoft has drastically increased security for the 2005 version resulting in a number of configuration steps to be able to talk to the db at all) I had a sample app going. Users of Ruby on Rails will feel at home since you can do nice stuff like:
[csharp] public void CreateUser() { User owner = new User(); owner.FirstName = “Peter”; owner.LastName = “Krantz”; owner.Create(); } [/csharp]
Then I wanted to try a TDD approach and this is where I am currently stuck. The MonoRail project wizard creates a sample test project with a sample test of a controller. However, according to people in the forum that approach is deprecated and a different way of testing controllers is described on the MonoRail wiki. But that approach does not work for testing your model classes and there is no information on how to get an application context to do that. Or maybe I have missed it when Googling for a solution.
Can I have just the O/RM please?
So, if I go back to the Page Controller pattern, can I please have an open source persistence framework that allows me to write code like above? I was happy to find this rather extensive list of persistence frameworks. The only problem is that most of them are not actively developed anymore. Or, they have simply disappeared as Microsoft is shutting down the GotDotNet website where many of them are/were hosted.
If you stick to the default pattern in ASP.NET you have a wealth of excellent tutorials and documentation from Microsoft and others. Going off the beaten track seems more difficult though. Hopefully the MonoRail issue will be solved and I can use it for my product idea.