public void ConfigureServices(IServiceCollection services)
{
services.Configure<IISServerOptions>(options =>
{
options.MaxRequestBodySize = 314572800;
});
services.AddControllersWithViews();
}
和web配置。
<security>
<requestFiltering>
<!-- This will handle requests up to 300MB -->
<requestLimits maxAllowedContentLength="314572800" />
</requestFiltering>
</security>
上面的应用是正确的,但默认的超时是2分钟。
asp core 3.1托管在iis中如何增加超时?
注:我的web.config
<aspNetCore processPath="dotnet" arguments=".\AspCoreTestFileUpload.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
for requestTimeout :不适用于进程内托管。对于进程内托管,模块会等待应用程序处理请求。
我必须使用inprocess hostingModel。
用以下代码解决
services.Configure<IISServerOptions>(options =>
{
options.MaxRequestBodySize = int.MaxValue;
});
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;
});
services.AddControllersWithViews();