# Wednesday, 26 September 2007

jaoo2007_1 I wanted to know more about alternative web frameworks out there. One such framework is MonoRail which is part of the Castle project like ActiveRecord which Oren and Hamilton spoke about yesterday.

MonoRail is a web framework which uses MVC and is built on top on ASP.NET. ASP.NET != WebForms. WebForms technology is built on top of ASP.NET like MonoRail and includes ViewState, life cycle, page structure, etc..

MonoRail was inspired by Ruby on Rails' Action Pack. It's not a direct port, however, it has its own identity and is not opinionated like is the case for Ruby on Rails. The mail goal of MonoRail is to separate concerns and getting rid of repetitive and tedious code. Controller => Model => View => User input => Controller.

Like with ActiveRecord a wizard is triggered when you create a new MonoRail project, also including the test project for TDD purposes. A lot of stuff is generated when you create a new projects just like you'd see in Ruby on Rails. Everything is spliut in Content, Controllers, Models, and Views folders. Content is for CSS, Javascript, stuff like that. The controllers folder is subdivded into a folder for each concrete controller.

All Controllers inherited from BaseController and has a number of Actions which are basically instance methods. View Engines. MonoRail has a number of ways of writing views, the default is NVelocity. You simple and complex ViewEngines, Brail for example allows for Boo code and the full power of .NET in the UI while NVelocity only provides a simple if statement. Layouts are outer views, the inner view is what the controller deails with. You specify the layout by way of attribute. The lauout contains the actual HTML while the inner lauout contains the dynamics parts of the UI. Filters is code than runs before or after specific pieces of code, e.g. you can use filters to change the theme of a site. Again attributes are used for associating the filter. Helpers is something that is made available to your View and abstracts away common HTML snippets, e-g- $Url for creating links. ViewComponents is a more elaborate way of creating stand alone controls.

SmartDispatcher allows you to bind the actions of a form directly to an Action (a method) on the controller, you only have to inherit from a different basecontroller to have this work. FormHelper and the DataBinder are for creating complex forms and you use them to bind to a specific class. You use the an attribute in concert with FormHelper to state what your type is called and to bind to HTML by $Form.TextField("customer.Name") and then you automatically get the customer served up with the correct values once you post back. Automatic Form-Validation is done by decoating the properties of a particular class with validation attributes. To trigger validation you simply say so on the action.

Combining the rest of Castle to Create Enterprise Applications. Castle is full of independent projects you can use the parts you like. The Windsor container is the most advanced of the bunch in comparison to Spring.NET, ObjectBuilder, NInject etc.. Castle Facilities provide integration to other products like IBatus, ActiveRecord, and more.

MonoRail is an organization of services. If you want to change the way MonoRails handles things you can change the corresponding service.

Not as well documented as WebForms. Has a learning curve. No designer support. It is easy to fall into the pit of success because MonoRail leads you in the direction of good design. Microsoft is working on something similar for the future and it should be about to be released in beta.

What does all this boil down to then? to my mind there are a lot of very good ideas in MonoRail but it seems to me that there are a lot of nook sand crannies to know before you get going. Oren's argument against this was that in the long run you will benefit from MonoRail because it makes it easier to fall into the pit of success. I certainly agree with that but there are a number of draw draws that I see. You loose the ability to do anything with SharePoint for example because it operates in the WebForms world, also you loose a lot of third party controls which are also built for the WebForms. It's encouraging to me that Microsoft is working on something similar because that will garner the widespread support needed to grow a third part business around a web framework based on the MonoRail principles.

posted on Wednesday, 26 September 2007 10:38:16 (Romance Daylight Time, UTC+02:00)  #    Comments [1] Trackback
Related posts:
Virtualized Development
JAOO 2008 Day 3
JAOO 2008 Day 2
JAOO 2008 Day 1
ReSharper 4.x Nuggets
The C# Keyword var is Evil
Tuesday, 02 October 2007 07:45:56 (Romance Daylight Time, UTC+02:00)
"You loose the ability to do anything with SharePoint for example because it operates in the WebForms world, also you loose a lot of third party controls which are also built for the WebForms."

You are absolutely right about loosing Microsoft. I would even add that it is Microsoft itself who is not viling to join the community. There are many cases where they make things more complicated than necessary just for the sake of locking developers into Microsoft world.
Comments are closed.