T4MVC基地控制器没有默认构造函数 [英] T4MVC Base controller doesn't have default constructor

查看:188
本文介绍了T4MVC基地控制器没有默认构造函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的控制器从anothe控制器,它不具有默认构造函数继承。 T4MVC生成以下构造函数假定基地控制器默认构造函数:

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) { }

我怎样才能解决这个问题呢?有意思的是,根据这个页面,版本00年4月2日的固定问题,当一个基本控制器没有按'吨有一个默认的构造函数。我还<一href=\"http://stackoverflow.com/questions/6730989/t4mvc-cannot-inherit-a-controller-class-which-has-no-default-constructor\">found这太问题,但我的基本控制器是不是通用的。

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.

推荐答案

如果你让你的基本控制器抽象这应该工作的罚款。我假定它从未需要被直接用作控制器?如果确实如此,那么你可以随时创建其他非抽象的派生类来处理。

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.

这篇关于T4MVC基地控制器没有默认构造函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆