Question

In MonoRail controllers can be adorned with the Helper attribute to make helpers available in views. Is there another way to register helpers, perhaps via configuration file or dependency injection, with controllers? I'm keen on avoiding creating a base controller just for the purposes of providing helpers and adding yet another controller to the controller hierarchy.

Was it helpful?

Solution

IControllerContext has a Helpers dictionary. All controllers expose IControllerContext via the ControllerContext property.

Another option is to implement an IHelperDescriptorProvider to replace the default one (which reads helper descriptors from [Helper] attributes). Your implementation could read helper configurations from a config or whatever you want.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top