使用接口在 MVC 中添加视图时无法选择“查看内容”下拉列表

发布于 2024-09-04 18:57:26 字数 554 浏览 4 评论 0原文

我在两个项目中外部定义了模型 - 一个核心项目和一个接口项目。

我从控制器中打开添加视图对话框,然后选择创建强类型视图

在下拉列表中,我可以选择 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

久伴你 2024-09-11 18:57:26

好吧,您始终可以选择实现接口的具体类,生成部分视图,然后手动删除所有不需要的内容。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文