Pri*_*ico 5 ajax razor asp.net-core
如果我的模型中有这样的属性:
[BindProperty]
public IPagedList<Product> Products { get; set; }
Run Code Online (Sandbox Code Playgroud)
然后当我尝试发帖时,我收到此错误:
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.
Run Code Online (Sandbox Code Playgroud)
该错误表明我可以在构造函数中将该属性设置为非空值,因此我尝试在构造函数中执行此操作:
Products = new PagedList<Product>(Enumerable.Empty<Product>(), 1, 10);
Run Code Online (Sandbox Code Playgroud)
但我得到了同样的错误。
| 归档时间: |
|
| 查看次数: |
3855 次 |
| 最近记录: |