开发者

Can't select View Content dropdown when adding view in MVC using Interfaces

开发者 https://www.devze.com 2023-01-02 19:25 出处:网络
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.

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 开发者_C百科to want to work with the interface.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号