我在 ActionResult 中传递两个列表变量,如下所示。
public ActionResult Index()
{
List<category> cat = _business.ViewAllcat().ToList();
List<Books> book = _business.ViewAllBooks().ToList();
return View(book);
}
Run Code Online (Sandbox Code Playgroud)
当我运行代码时,出现以下错误
传递到字典中的模型项的类型为 System.Collections.Generic.List1[Durgesh_Bhai.Models.category],但此字典需要 System.Collections.Generic.IEnumerable1[Durgesh_Bhai.Models.Books] 类型的模型项。
当我在 Actionresult 中只使用一个 List 时,它工作正常。