Maximum Download Size for ASP.MVC CORE

How to set maximum download size for ASP.NET CORE application?

In the past, I was able to install it in the web.config as follows:

 <system.webServer> <security> <requestFiltering> <requestLimits maxAllowedContentLength="52428800" /> </requestFiltering> </security> </system.webServer> 
+7
asp.net-mvc asp.net-core
source share
2 answers

You can configure the maximum limit for multi-page downloads in the ConfigureServices method:

 public void ConfigureServices(IServiceCollection services) { services.Configure<FormOptions>(options => { options.MultipartBodyLengthLimit = 52428800; }); services.AddMvc(); } 

You can also configure MaxRequestBufferSize with services.Configure<KestrelServerOptions> , but it looks like it will be deprecated in the next version.

+1
source share

Two ways to do this:

1. Use of useful application settings - in the method to configure services .

 services.Configure<FormOptions>(options => { options.MultipartBodyLengthLimit = 52428800; }); 

2.Using the RequestFormSizeLimit attribute - for specific actions. - It is not yet available in the official Unofficial package

+1
source share

All Articles