ASP .NET Core Razor:模型绑定复杂类型不得是抽象或值类型,并且必须具有无参数构造函数

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)

但我得到了同样的错误。

Pri*_*ico 5

当我删除 [BindProperty] 时,它起作用了。我的印象是我需要它来绑定 Razor 页面上的属性,但我想不是?