Last active
October 27, 2019 12:54
-
-
Save Legends/2e997d3c8be9575e5fc7e282cc62b616 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // If you are using **IIS Express** as host, then use `Server features` to increase the `MaxRequestBodySize` | |
| public void Configure(IApplicationBuilder app, IWebHostEnvironment env) | |
| { | |
| app.Use(async (context, next) => | |
| { | |
| context.Features.Get<IHttpMaxRequestBodySizeFeature>().MaxRequestBodySize = null; // unlimited I guess | |
| await next.Invoke(); | |
| }); | |
| } | |
| // If you are using **Kestrel**: | |
| public static IHostBuilder CreateHostBuilder(string[] args) => | |
| Host.CreateDefaultBuilder(args) | |
| .ConfigureWebHostDefaults(webBuilder => | |
| { | |
| webBuilder.UseStartup<Startup>.UseKestrel(o => o.Limits.MaxRequestBodySize = null); | |
| }); | |
| // If you are using **IIS** --> **web.config**: | |
| // This sample contains dummy values, configure them appropriately. | |
| <?xml version="1.0" encoding="utf-8"?> | |
| <configuration> | |
| <system.web> | |
| <httpRuntime maxRequestLength="2073741824" /> // kbytes | |
| </system.web> | |
| <system.webServer> | |
| <security> | |
| <requestFiltering> | |
| <requestLimits maxAllowedContentLength="2073741824" /> // bytes | |
| </requestFiltering> | |
| </security> | |
| </system.webServer> | |
| </configuration> | |
| // --------------------------------------------------------------------------------------------------------------- | |
| // The server feature `FormOptions` can also be set! But when and where does it apply? | |
| public void ConfigureServices(IServiceCollection services) | |
| { | |
| services.Configure<FormOptions>(x => | |
| { | |
| x.ValueLengthLimit = int.MaxValue; | |
| x.MultipartBodyLengthLimit = int.MaxValue; | |
| x.MultipartBoundaryLengthLimit = int.MaxValue; | |
| x.MultipartHeadersCountLimit = int.MaxValue; | |
| x.MultipartHeadersLengthLimit = int.MaxValue; | |
| }); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment