T4MVC Base controller doesn't have default con

2020-07-13 14:46发布

问题:

My controller is inherited from anothe controller which doesn't have default constructor. T4MVC generates the following constructor which assumes base controller has default constructor:

protected MyControllerController(Dummy d) { }

How can I resolve this problem? Interesting enough, according to this page, version 2.4.00 "fixed issue when a base controller doesn't have a default ctor". I also found this SO question, but my base controller is not generic.

回答1:

This should work fine if you make your base controller abstract. I assume that it never needs to be used directly as a controller? If it does, then you can always create another non-abstract derived class to handle that.