且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在ASP .NET Core 3.1中设置请求超时

更新时间:2023-02-09 09:35:09

问题已解决:

在网络配置中:

<security>
    <requestFiltering>
      <!-- This will handle requests up to 300MB -->
      <requestLimits maxAllowedContentLength="314572800" />
    </requestFiltering>
  </security>

和在asp核心3.1 ConfigureServices中: 我不明白原因,但是这段代码解决了问题

and in asp core 3.1 ConfigureServices : I did not understand the reason, but this piece of code solved the problem

services.Configure<FormOptions>(options =>
            {
                options.ValueLengthLimit = int.MaxValue;
                options.MultipartBodyLengthLimit = long.MaxValue; // <-- ! long.MaxValue
                options.MultipartBoundaryLengthLimit = int.MaxValue;
                options.MultipartHeadersCountLimit = int.MaxValue;
                options.MultipartHeadersLengthLimit = int.MaxValue;
            });