非常简单的 MVC 应用程序,一个模型,一个松散类型
List<Model>
的视图和控制器通过ViewBag
.
在我更新模型之前一切正常。现在我得到“模型”不包含“属性名称”的定义,尝试重建应用程序并清理临时文件夹。
我需要清理什么才能正确重新编译?
~Edit:无法找到的属性已添加到未删除的模型中。我正在尝试在视图中使用这个新属性。
~编辑:型号:
public class App
{
public String title { get; set; }
public String featured { get; set; }
public String subtitle { get; set; }
public String thumb { get; set; }
public String logo { get; set; }
public String web { get; set; }
public String email { get; set; }
public String phone { get; set; }
public String download { get; set; }
public String body { get; set; }
public List<String> tags { get; set; }
public List<String> features { get; set; }
public List<Highlight> highlights { get; set; }
}
控制器:
ViewBag.apps = (from xml in XmlResources.Root.Descendants("app")
select new App
{
title = xml.Element("title").Value,
featured = xml.Attribute("featured").Value,
subtitle = xml.Element("subtile").Value,
thumb = xml.Element("thumb").Value,
logo = xml.Element("logo").Value,
web = xml.Element("web").Value,
email = xml.Element("email").Value,
phone = xml.Element("phone").Value,
download = xml.Element("download").Value,
body = xml.Element("body").Value,
tags = (from x in xml.Descendants("tag") select x.Value).ToList(),
features = (from x in xml.Descendants("feature") select x.Value).ToList(),
highlights = (from x in xml.Descendants("highlight") select new Highlight { type = x.Attribute("type").Value, src = x.Attribute("src").Value }).ToList()
}).ToList();
看法:
@using eduApps.Models;
@for (var i = 0; i < ViewBag.apps.Count; i++)
{
@{ if(!String.IsNullOrEmpty(ViewBag.apps[i].web))
{
<span>Web:</span><a href="@ViewBag.apps[i].web" title="@ViewBag.apps[i].title">@ViewBag.apps[i].web</a>
}
}
}
错误:“eduApps.Models.App”不包含“web”的定义