T4MVC Base controller doesn't have default constructor

坚强是说给别人听的谎言 提交于 2019-12-21 15:14:13

问题


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.



来源:https://stackoverflow.com/questions/11584949/t4mvc-base-controller-doesnt-have-default-constructor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!