Creating URL’s in Mono Rail

Posted on Март 6, 2008. Filed under: .net, asp, Castle project, coding, Monorail |

They got a very simple URLHelper for Castle Project, it is used like:


And it DOES NOT take additional parameters, like some «id» or sth in a form, that would not make you specify all special symbols, ‘=’, ‘?’ and ‘&’ .. I should mention lack of up-to-date documentation. After googling for some time I realized, it would be better to write my own one. (I hope, I did not reinvent the will) I called it MyUrlHelper, extending it from AbstractHelper. To use it with NVelocity, supply it with action (yes, it does not takes controller as a parameter now) and a dictionary as the second parameter:

$MyUrlHelper.For("YourAction", "%{id=$}")

and it will output a correctly formed URL. Place it in «Helpers» directory under your VS project and name it MyUrlHelper (by default). Then in corresponding controller, the one that passes data to your views, write something like this:

public class YourController : BaseController

and it’s gonna work. Be sure, you explicilty mention MyUrlHelper in HelperAttribute attached to the controller, otherwise it won’t work!
It can be used without any restrictions, download it from

UPD: Well, it seems, I reinvented the will ;) I had I version of MonoRail v 1 RC3, that had non-virtual methods of UrlHelper, but accordingly to this forum thread they made them virtual on about Dec 27, 2007.


Make a Comment

Добавить комментарий

Заполните поля или щелкните по значку, чтобы оставить свой комментарий:


Для комментария используется ваша учётная запись Выход /  Изменить )

Google+ photo

Для комментария используется ваша учётная запись Google+. Выход /  Изменить )

Фотография Twitter

Для комментария используется ваша учётная запись Twitter. Выход /  Изменить )

Фотография Facebook

Для комментария используется ваша учётная запись Facebook. Выход /  Изменить )


Connecting to %s

Liked it here?
Why not try sites on the blogroll...

%d такие блоггеры, как: