1 2 3 4 5 6 7 8 9 10 |
<?xml version="1.0" encoding="utf-8"?> <configuration> <system.webServer> <security> <requestFiltering> <requestLimits maxAllowedContentLength="104857600" /> </requestFiltering> </security> </system.webServer> </configuration> |
1 2 3 4 5 6 7 8 |
public static IWebHostBuilder CreateWebHostBuilder(string[] args) => WebHost.CreateDefaultBuilder(args) .UseStartup<Startup>() .UseKestrel(options => { options.Limits.MaxRequestBodySize = 52428800; //50MB }); } |
1 2 3 4 5 6 |
[HttpPost] [RequestSizeLimit(40000000)] public async Task<IActionResult> UploadFiles(IFormFile file) { //TODO: Save file } |
위의 두 방법 보다는 file upload 하는 딱 그 함수만 제약을 거는것이 더 안전할것처럼 보인다.
Leave a Reply