티스토리 뷰
API
[asp.net/.netcore] asp.net에서 파일 업로드 시 대용량(large) 파일 업로드 하는 방법(asp.net request body too large 해결법)
개발자 고포고 2022. 3. 4. 17:07반응형
[asp.net/.netcore] asp.net에서 파일 업로드 시 대용량(large) 파일 업로드 하는 방법(asp.net request body too large 해결법)
기준 버전 .NET Core 3.1
#기본적으로 asp.net에서는 30mb이상의 파일업로드가 불가능하여 제약을 풀어야한다.
#[web.config] - 용량제한을 1GB 이상으로 올려준다.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="1073741824" />
</requestFiltering>
</security>
</system.webServer>
</configuration>
#[Startup.cs] - 각 환경별로 제약을 풀어준다
public void ConfigureServices(IServiceCollection services)
{
services.AddDistributedMemoryCache();
services.Configure<FormOptions>(x =>
{
x.ValueLengthLimit = int.MaxValue;
x.MultipartBodyLengthLimit = int.MaxValue;
x.MultipartHeadersLengthLimit = int.MaxValue;
});
services.Configure<IISServerOptions>(options =>
{
options.MaxRequestBodySize = int.MaxValue;
});
services.Configure<KestrelServerOptions>(options =>
{
options.Limits.MaxRequestBodySize = int.MaxValue;
});
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UseStaticFiles();
}
#[Controller.cs] 각 컨트롤러에 요청 시 리밋을 명시해준다
[Route("SaveFile")]
[RequestSizeLimit(1073741824)]
[RequestFormLimits(MultipartBodyLengthLimit = 1073741824)]
[HttpPost]
public JsonResult SaveFile()
{
}
Controller.cs]
#asp.net #.net core #c# #limit #large #too #asp.net request body too large
반응형
'API' 카테고리의 다른 글
[aws/lambda] AWS Lambda 기본 생성 및 Helloworld (0) | 2022.07.12 |
---|---|
[aws/mediaconvert] vod 스트리밍 서버 구축하기 - mediaconvert S3생성 및 JobTemplate만들기(1/2) (0) | 2022.07.12 |
[API] QR코드 생성 API, code(코드)에서 QR생성하기 (0) | 2021.11.10 |
댓글
반응형