How to increase upload file size in ASP.NET Core

If the request body size exceeds the configured max request body size limit, the call to Request.Body.ReadAsync will throw an IOException. If this exception is uncaught, Kestrel will respond with a 413 Payload Too Large response and HttpSys will respond with a generic 500 Internal Server Error response (source).

[HttpPost]
[RequestSizeLimit(100_000_000)]
public IActionResult MyAction([FromBody] MyViewModel data)
{
[HttpPost]
[DisableRequestSizeLimit,
RequestFormLimits(MultipartBodyLengthLimit = int.MaxValue,
ValueLengthLimit = int.MaxValue)]
public async Task<ActionResult> BulkAdd(string schema, IFormFile file)
{

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store