【问题标题】:Missing model class when adding a view in ASP.NET MVC 3在 ASP.NET MVC 3 中添加视图时缺少模型类
【发布时间】:2011-06-21 08:46:58
【问题描述】:

在我的 ASP.NET MVC 3 项目中,我引用了我的 DomainModel 项目。

当我尝试创建强类型视图时会出现问题。在模型类列表中,我的 DomainModel 模型不存在。

我做了以下尝试但没有成功(来自另一个线程):

-remove reference to the library containing the model
-clean project
-close VS
-reopen VS
-rebuild project (VS throws errors)
-re-add reference to the model library
-rebuild project

我也尝试将VS2010更新到VS2010 SP1同样的问题。

有什么建议吗?

【问题讨论】:

  • 我也有同样的问题。
  • 当我的模型在单独的类库中时,我似乎才遇到这个问题。

标签: visual-studio-2010 asp.net-mvc-3 strongly-typed-view


【解决方案1】:

如果您在对话框中看不到模型,请尝试直接从视图中调用它,如下所示:

@model  IEnumerable<Ieagle.WebSelfCare.Models.InvoicingIndex>

如果你有一个 IEnumerable 模型,否则

@model Ieagle.WebSelfCare.Models.Person

如果您无法像这样访问您的模型,那么您可能会在模型中遇到问题

【讨论】:

  • 我自己输入模型时没有问题,我只是厌倦了为什么它在添加视图对话框中不起作用
猜你喜欢
  • 2011-10-24
  • 1970-01-01
  • 2011-07-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-01-20
相关资源
最近更新 更多