开发者

Asp.net MVC - Asynch controller get functionality from my base controller

I have 开发者_开发问答a base controller which is subclassed from a standard mvc controller. This containers lots of useful methods specific to a Controller.

I now need to have some asych functionality in one of my new controllers

However, to do that you need to create a controller that subclasses AsyncController

But I also want to access functionality in my base controller

Obviously multiple inheritance isn't possible

so how do I get around this?


You could externalize the functionality you are willing to reuse into a service layer, action filter, authorization filter, model binder, ... it will depend on the functionality you are willing to reuse so that you could easily switch the base controller to an async controller and still preserve the functionality. If you want to use async controllers you will need to derive from AsyncController.


You could make your controller class inherit IAsyncManagerContainer and IAsyncController, then implement this functionality yourself, perhaps using the code from MVC source code. You could even encapsulate this in its own class that you delegate the functionality to.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜