sproaty wrote:
It's a pain - the controllers generally have helper methods that would need to be either refactored out into another class or duplicated into your own controller.
Fair point, but to go the inherited class route, don't you have to mark properties as protected? You could mark those utility methods as public and have at them. You'd create some dependencies because you'd have to new up a Controller for the purpose of using those utilities, but no more than inheriting or partialing.
sproaty wrote:
Also, when rendering a view from my own re-routed action, I had to prefix the viewpath with "../[OriginalControllerName]" otherwise it'd be trying to render views from the name of my own controller.
I certainly don't see that as a negative. It gives you the option to create the views you want OR use what is already there without modifying core code.
sproaty wrote:
I also had to update any Html.Partial calls in these views, to append the original controller name, otherwise it'd be trying to render partials based on my new controller's name (e.g. re-mapped CatalogController.Product to my own CustomCatalogController and rendering ../Catalog/ProductTemplate.Simple then this view would try and render the partials from /CustomCatalog/_partial
Sounds like a case where you'd be better off not writing an across the board /Catalog to /CustomCatalog route, and instead just use /Catalog/Action to /CustomCatalog/CustomAction.
Ex
routes.MapRoute("CustomCatalogAction", // Route name
"/NamedAction", // URL with parameters
new { controller = "CustomCatalog", action = "CustomAction" }
// Parameter defaults );
routes.MapRoute("CustomCatalogAction2", // Route name
"/Catalog/NamedAction", // URL with parameters
new { controller = "CustomCatalog", action = "CustomAction" }
// Parameter defaults );
You could also consider getting seriously crazy and looking at Action Filters, and making a decision based on the request context as to where to redirect the call. Sorta like
here