使用MVC 3和Razor视图引擎。我有以下视图:
@model dynamic
@{
var products = (List<ListItemBaseModel>)Model.Products;
var threshold = (int)(Model.Threshold ?? 1);
var id = Guid.NewGuid().ToString();
}
使用以下代码从另一个视图调用它:
@Html.Partial("PartialViewName", new { Products = Model, Threshold = 5 })
在这两个视图中,当我进行调试并查看Model时,它似乎包含了正确的对象。
但是当我执行代码时,在var products =
这一行会出现错误:
'object' does not contain a definition for 'Products'
为什么我会看到这个错误?
当我在调试模式下查看Model对象时,它看起来都没问题(拥有2个属性:Products和Threshold)