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

编程入门 行业动态 更新时间:2024-10-25 08:20:39
本文介绍了如何在ASP .NET Core 3.1中设置请求超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述
  • 从Visual Studio中选择创建新项目".选择ASP.NET Core 3.1
  • 在IIS中发布并托管
  • 增加此代码的上传文件大小:
public void ConfigureServices(IServiceCollection services) { services.Configure<IISServerOptions>(options => { options.MaxRequestBodySize = 314572800; }); services.AddControllersWithViews(); }

和网络配置:

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

以上正确适用 但默认超时时间是2分钟

The above applies correctly but defualt timeout is 2 min

如何在iis中托管的asp core 3.1中增加超时时间?

How increase timeout in asp core 3.1 hosted in iis?

注意:我的web.config

Note : my web.config

<aspNetCore processPath="dotnet" arguments=".\AspCoreTestFileUpload.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />

对于requestTimeout: 不适用于进程内托管.对于进程内托管,该模块等待应用处理请求.

for requestTimeout : Doesn't apply to in-process hosting. For in-process hosting, the module waits for the app to process the request.

docs.microsoft/zh-cn/aspnet/core/host-and-deploy/aspnet-core-module?view=aspnetcore-3.1#attributes-of -the-aspnetcore-element

我必须使用进程内托管模型

推荐答案

问题已解决:

在网络配置中:

<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; });

更多推荐

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

本文发布于:2023-11-12 01:46:25,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1580162.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何在   ASP   NET   Core

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!