使用接口在 MVC 中添加视图时无法选择“查看内容”下拉列表
我在两个项目中外部定义了模型 - 一个核心项目和一个接口项目。
我从控制器中打开添加视图对话框,然后选择创建强类型视图。
在下拉列表中,我可以选择 MyProject.Model.Core.OrderDetails 等具体类型,但不能选择 MyProject.Model.Interface.IOrderDetails 等接口类型那里。
我可以手动输入接口类,一切正常,但是允许您选择创建、删除、列表等脚手架的查看内容菜单被禁用。
在MVC中使用接口有什么问题吗?还是我还缺少其他东西?
编辑:只是澄清一下,如果我选择具体对象和我想要的任何脚手架,我就可以在视图 Page 指令中编辑 Inherits
标记,一切正常,所以没有遗漏参考资料或任何东西。只是向导似乎不想使用该界面。
I have my Model defined externally in two projects - a Core project and an Interface project.
I am opening the Add View dialogue from my controller, and selecting Create a strongly typed view.
In the drop down list, I can select the concrete types like MyProject.Model.Core.OrderDetails, but the interface types like MyProject.Model.Interface.IOrderDetails aren't there.
I can type the interface class in manually and everything works, but then the View content menu that lets you select the Create, Delete, List, etc scaffolding is disabled.
Is there some problem with using interfaces in MVC? Or is it something else I'm missing?
Edit: Just to clarify, if I select the concrete object and the whatever scaffolding I want, I can then edit the Inherits
tag in the view Page directive and everything works fine, so there's no missing references or anything. It's just the wizard doesn't seem to want to work with the interface.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,您始终可以选择实现接口的具体类,生成部分视图,然后手动删除所有不需要的内容。
Well, you could always select the concrete class implementing the interface, generate the partial view, and manually remove all the stuff that's not needed.