当我尝试通过模型列表从视图到控制器 post 200 多条记录时,它在控制器 HTTP POST 中始终显示为 null MVC 中的操作

When I try to post 200 plus records through model list from view to controller it is showing always null in controller HTTP POST Action in MVC

我正在尝试将模型列表从视图提交到控制器。它适用于列表中 200 条以下的记录。但是当我尝试通过模型对象从视图到控制器 post 超过 200 条记录时,它总是在控制器中显示 null。

The code which I have written as follows -

**In Model -**


    public partial class SlsaudtMerchId
        {
            [Key]`enter code here`
            [Required]
            public int Company { get; set; }enter code here
            public int Store { get; set; }
            public string TermLoc { get; set; }
            [Key]
            [Required]
            public int TermId { get; set; }
            public DateTime Updated { get; set; }
            public string Inactive { get; set; }
        }
        public class SlsAuditMerchId_Cust
        {
            /// <summary>  
            /// To hold list of orders  
            /// </summary>  
            public List<SlsaudtMerchId> SlsaudtMerchIds { get; set; }
    
        }
    
    **In View -**
    
  @model PostListData.Models.SlsAuditMerchId_Cust    
    @{
        ViewData["Title"] = "PlaceOrder";
    }
    
    <h1>PlaceOrder</h1>
    
    <p>
        <a asp-action="Create">Create New</a>
    </p>
    <div>
    
    </div>
    @using (Html.BeginForm(FormMethod.Post))
    {
        @Html.AntiForgeryToken()
    
        <div class="form-horizontal">
            <div class="form-group">
                <div class="col-md-offset-2 col-md-10 text-right">
                    <input type="button" value="Add Product" class="btn btn-primary" />
                </div>
            </div>
            <div class="form-group">
                <div class="col-md-12">
                    <table class="table table-condensed table-hover">
                        <tr>
                            <th>
                                Product Code
                            </th>
                            <th>
                                Product Name
                            </th>
                            <th>
                                Quantity
                            </th>
                            <th>
                                Price
                            </th>
                            <th>
                                Total Amount
                            </th>
                        </tr>
                        @{
                           
                            int i = 0;
                            foreach (var item in Model.SlsaudtMerchIds.ToList())
                            {
    
                                            <tr>
                                                <td>
    
    
                       @Html.EditorFor(o => o.SlsaudtMerchIds[i].Company, new { @id = "ItemCode_" + i })
                                                </td>
                                                <td>
                                                    @Html.EditorFor(o => o.SlsaudtMerchIds[i].Store, new { @id = "ProductName_" + i })
                                                </td>
                                                <td>
                                                    @Html.EditorFor(o => o.SlsaudtMerchIds[i].TermLoc, new { @id = "Qty_" + i })
                                                </td>
                                                <td>
                                                    `enter code here`@Html.EditorFor(o => o.SlsaudtMerchIds[i].TermId, new { @id = "Price_" + i })
                                                </td>
                                                <td>
                                                    @Html.EditorFor(o => o.SlsaudtMerchIds[i].Updated, new { @id = "Updtd_" + i })
                                                </td>
                                                <td>
                                                    @Html.EditorFor(o => o.SlsaudtMerchIds[i].Inactive, new { @id = "inactv_" + i })
                                                </td>
    
                                            </tr>
    
                                i++;
                            }
                        }
                    </table>
                </div>
            </div>
            <hr />
            <div class="form-group">
                <div class="col-md-offset-2 col-md-10 text-center">
                    <input type="submit" value="Place Order" class="btn btn-primary" />
                </div>
            </div>
        </div>
    }
    
    **In Controller :**
      public IActionResult Index()
            {
                List<SlsaudtMerchId> objOrder = new List<SlsaudtMerchId>()
                       //ObjOrder will be populated from API
                SlsAuditMerchId_Cust ObjOrderDetails = new SlsAuditMerchId_Cust();
                ObjOrderDetails.SlsaudtMerchIds = objOrder;
                return View(ObjOrderDetails);
            }
           [HttpPost]
          `enter code here`  public IActionResult Index(SlsAuditMerchId_Cust MerchId)
              // It is sowing null for above 200 records`enter code here`
            {
    
    
                return View();
            } 

我不明白我在这里犯了什么错误。当我尝试通过模型列表提交低于 200 (175-180) 条记录时,它成功提交了控制器中的列表参数捕获所有 175 条记录列表。但是当我尝试增加列表的计数时,它在控制器的列表参数中显示为 null。

请帮帮我, 提前致谢

素门.

您可以在 startup

中添加以下代码
services.AddMvc(options => {
   options.MaxModelBindingCollectionSize = 100000;
});          
services.Configure<FormOptions>(options => {
  options.ValueCountLimit = int.MaxValue; 
  options.ValueLengthLimit = int.MaxValue;             
  options.MultipartHeadersLengthLimit = int.MaxValue;
});