'.NET 6 Long http post form not not passing data into the model

I have a html form which contains different kind of elements like text-boxes or combo-boxes. The combo-boxes are configured as multiple which means, that you could select one item or a few thousand and here is the problem.

If you select only a few items like 100 the submit is working perfectly, but if you add thousands of elements in the combo-box the C# Model in the HTTP Post method is null.

I've tried:

1.[DisableRequestSizeLimit] but nothing changed.

2 If i add the code below i get a HTTP Status Code 415 Error Unsupported Media Type:

builder.Services.Configure<FormOptions>(x =>
    {
        x.BufferBody = false;
        x.KeyLengthLimit = 2048; // 2 KiB
        x.ValueLengthLimit = 4194304; // 32 MiB
        x.ValueCountLimit = 8000;// 1024
        x.MultipartHeadersCountLimit = 32; // 16
        x.MultipartHeadersLengthLimit = 32768; // 16384
        x.MultipartBoundaryLengthLimit = 256; // 128
        x.MultipartBodyLengthLimit = 134217728; // 128 MiB
    });

Whats the problem? I think my http post body is to long. But how can i increase the form-data-request size?

Thank you for your help.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source