I decided that my controllers were a bit confused and decided to adopt a pipeline-style system, as I used in the WebAPI project. The conveyor consists of actions that are becoming more and more common, i.e. ViewAccountDetailsAction> AccountAction> AuthenticatedAction> EmptyAction. Actions are also added to pipleline in order of inheritance, and also expose elements or abstract methods for different scenarios.
My problem is how to return views from pipeline elements. In the WebAPI example, it was as simple as returning IHttpActionResult, which should not have done any kind of rendering, however MVC is required to work out its answers differently, with an additional Razor step.
Since controllers reveal internal protectedhelper methods such as View()or RedirectToAction, I cannot use them outside the controllers themselves.
Is there an elegant way to do this? I saw several ways to do this, each of which was either cumbersome or gave me uncomfortable feelings.
My most preferred way at the moment is to create a base class internalthat hides protected methods and makes them internal, and calls the base methods. Then the controller instance will be provided to create the instance. Is there anything too bad in this regard? I cannot think of any abuses, but I would like to know if there is any community consensus on this issue.
source
share