Reputation: 32400
I'm working on a web application. One of my co-workers has written some asp.net forms pages. The page classes all inherit from BasePageClass
, which of course inherits from the Page
class. I wish to add some MVC controllers that I've been told need to use the same logic implemented in the BasePageClass
. Ordinarily, I would want to inherit the functions in the BasePageClass
in the controller classes, but this breaks the inheritance hierarchy.
What is the best practice for solving this problem?
Upvotes: 2
Views: 210
Reputation: 23613
If there is common functionality, I would suspect that this functionality should be separated out from the page/controller anyway. This is better OOP/D. Then both your controller base page and your System.Web.UI.Page base can both have properties returning classes that contain this common functionality.
(I've seen a lot of cases where stuff is crammed into the base page that should be elsewhere. Your need for this functionality to be in both the Pages and Controllers is likely just bringing this poor design to light, rather than being a problem in itself.)
Less likely to be what you want, but still a possibility:
Upvotes: 2