【发布时间】:2019-09-19 10:52:39
【问题描述】:
如果我的模型中有这样的属性:
[BindProperty]
public IPagedList<Product> Products { get; set; }
然后当我尝试发布时,我收到此错误:
An unhandled exception occurred while processing the request.
InvalidOperationException: Could not create an instance of type 'X.PagedList.IPagedList`1[Data.Models.Product, Data, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]'. Model bound complex types must not be abstract or value types and must have a parameterless constructor. Alternatively, set the 'Products' property to a non-null value in the 'Areas.Catalog.Pages.ProductListModel' constructor.
错误说我可以在构造函数中将属性设置为非空值,所以我尝试在构造函数中这样做:
Products = new PagedList<Product>(Enumerable.Empty<Product>(), 1, 10);
但我得到了同样的错误。
【问题讨论】:
标签: ajax asp.net-core razor