Hellow,我正在尝试将一个对象列表传递给一个视图,但我遇到了这个错误。
这是我在控制器中的代码:
ReliableMessageListener
视图中的代码:
public IActionResult Index()
{
var Page = new PageSettings("HomeControllerIndex");
ViewData["Page"] = Page;
var NavBar = new NavBarSettings(Page.NavBar);
ViewData["NavBar"] = NavBar;
return View();
}
答案 0 :(得分:0)
感谢您的评论,只是让我对我的解决方案更加谨慎,所以这是正确的aproch:
public IActionResult Index()
{
var Page = new PageSettings("HomeControllerIndex");
ViewData["Page"] = Page;
var NavBar = new NavBarSettings(Page.NavBar);
ViewBag.NavBar = NavBar;
return View();
}
@using System.IO;
@using System.Reflection;
@using CMP.Helpers;
@{
var Items = (NavBarSettings)ViewData["NavBar"];
}
@foreach (NavBarItem Item in Items.NavBarItems)
{
}