小编May*_*esh的帖子

如何将多个参数传递给视图?

我在 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 时,它工作正常。

.net c# asp.net-mvc

5
推荐指数
1
解决办法
1万
查看次数

标签 统计

.net ×1

asp.net-mvc ×1

c# ×1