Sending large amount of data from view to controller in asp.net

To be more specific let me explain what did I encounter.
I was trying to submit a List of data from view to controller. I was able to submit some data successfully without any problem. But the problem arises when the data is more than around a list of 250 items and more than that. When I click a submit button it passes a NULL value when I debug it. There is no error with my code because I have submitted a list of 100 items to the controller without any problem. I guess there will be something that I have to specify so that It will also send a large number of lists.
Here I’m not using ajax or any javascript code to submit the form. I’m submitting it directly to the controller using post request.

I have posted some snippet of my code below to describe it more precisely.

View

    <form method="post" action="SubmitList">
                <div class="row"> 
                    <div class="col-md-12" style="padding-top:1%">
<input type="submit" value="PASS" class="btn btn-primary" style="float:right;" />
                        <div class="box-body">
                            <table id="#example1" class="table table-bordered table-striped">
                                <thead>
                                    <tr>
                                        <th>No</th>
                                        <th>Name</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    @{
                                        int i = 1;
                                    }
                                    @for (int j = 0; j < Model.Count(); j++)
                                    {
                                        <tr>
                                            <td>@Html.Raw(i++)</td>
                                            @Html.HiddenFor(item => item[j].Id, new { htmlAttributes = new { @class = "form-control" } })
                                            <td>
                                                @Html.DisplayFor(item => item[j].FullName) 
                                            </td>
                                        </tr>
                                    }
                                </tbody>
                                <tfoot>
                                </tfoot>
                            </table>
                        </div>
                    </div>
                </div>
            </form>

Controller

[AuthorizedAction]
[HttpPost] 
public async Task<IActionResult> SubmitList(List<Student> students)
    {
////
    }

Can you tell me what’s wrong with my code, please

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

Please try this in Startup#ConfigureServices

services.Configure<FormOptions>(options => options.ValueCountLimit = 1000); // you may want to adjust this limit

Reference: https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.http.features.formoptions


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x