NET Core 应用程序 IIS 运行报错 502.3-Gateway & IIS 7.x Application Request Routing(ARR) 502错误的解决方法(转载)
1.NET Core 应用程序 IIS 运行报错 502.3-Gateway
将 NET Core 应用程序部署在 IIS 环境,默认配置下,如果任务执行时间长达 2 分钟,会收到如下错误(Bad Gateway):
如果要执行长时间任务,可以修改发布后的 web.config 文件的 system.webServer / aspNetCore 节,为其添加 requestTimeout 属性:
<system.webServer> <aspNetCore requestTimeout="00:20:00" ... /> </system.webServer>
属性说明:
- requestTimeout
可选的 timespan 属性。
指定 ASP.NET 核心模块将等待侦听 %aspnetcore_port%的进程的响应的持续时间。
默认值为“00:02:00”。
requestTimeout 必须指定整分钟数,否则它将默认为 2 分钟。
- ASP.NET Core Module configuration reference
https://docs.microsoft.com/zh-cn/aspnet/core/hosting/aspnet-core-module - .NET Core publish to IIS - HTTP Error 502.3 - Bad Gateway - The specified CGI application encountered an error and the server terminated the process
https://stackoverflow.com/questions/39756042/net-core-publish-to-iis-http-error-502-3-bad-gateway-the-specified-cgi-ap/48164725#48164725
原文链接:NET Core 应用程序 IIS 运行报错 502.3-Gateway - FeelRose - 博客园 (cnblogs.com)
2.IIS 7.x Application Request Routing(ARR) 502错误的解决方法
IIS ARR可实现基于反向代理的Server Farms,默认配置会导致在需要长时间操作超时的502.3错误,具体解释可以参考http://blogs.iis.net/richma/archive/2010/07/03/502-3-bad-gateway-the-operation-timed-out-with-iis-application-request-routing-arr.aspx
文章也提供了命令行执行相关操作:
Server Farm : appcmd.exe set config -section:webFarms /[name='ArrFarm'].applicationRequestRouting.protocol.timeout:"00:00:45" /commit:apphost
这个操作也可以通过IIS的控制面板进行操作:
修改这个Time-out为 足够长的时间值就可以解决。
原文链接:IIS 7.x Application Request Routing(ARR) 502错误的解决方法_张善友的技术博客_51CTO博客
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 清华大学推出第四讲使用 DeepSeek + DeepResearch 让科研像聊天一样简单!
· 推荐几款开源且免费的 .NET MAUI 组件库
· 实操Deepseek接入个人知识库
· 易语言 —— 开山篇
· 【全网最全教程】使用最强DeepSeekR1+联网的火山引擎,没有生成长度限制,DeepSeek本体