Can you set request timeout in asp.net core 2.0 hosted in IIS from C# code?
No, there is no way to do that as you described. But according to the documentation you can just add web.config to your project and specify this (and other) setting value:
If a
web.config
file isn't present in the project, the file is created with the correct processPath and arguments to configure the ASP.NET Core Module and moved to published output.If a
web.config
file is present in the project, the file is transformed with the correct processPath and arguments to configure theASP.NET Core Modul
e and moved to published output. The transformation doesn't modify IIS configuration settings in the file.The
web.config
file may provide additionalIIS
configuration settings that control activeIIS
modules. For information onIIS
modules that are capable of processing requests withASP.NET Core
apps, see theIIS
modules topic.To prevent the Web SDK from transforming the web.config file, use the
IsTransformWebConfigDisabled
property in the project file.
Comments
-
Sam Leach almost 2 years
Is there a way to set
requestTimeout
from C# instead of needing to setrequestTimeout
in theweb.config
?asp.net core 2.0 hosted in IIS
<?xml version="1.0" encoding="utf-8"?> <configuration> <system.webServer> <handlers> <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" /> </handlers> <aspNetCore requestTimeout="00:00:04" processPath="dotnet" arguments=".\Foo.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" /> </system.webServer> </configuration>
-
Dnyaneshwar123456 about 5 yearsHow to add Web.config if it's not present..." the file is created with the correct processPath and arguments to configure the ASP.NET Core Module " means? could please elaborate.
-
Dmitry Pavlov about 5 years@Dnyaneshwar123456 when you use IIS
web.config
is generated after you publish your web project. But you can just add this file to the porject root. Check this to see what can be configured, what not, and how to configure the rest. -
Dnyaneshwar123456 about 5 yearsI tried...I add web.config in my .net core 2.0 project and add Request timeout of 20 min for a request in API project. but still no luck...Same error getting when the Mobile app sends huge data...for publish we use Azure server hence don't know exactly what settings Azure server have.
-
Catchops over 3 yearsIf you are using an InProcess hosting model, the requestTimeout attribute in the Web.Config is ignored. docs.microsoft.com/en-us/aspnet/core/host-and-deploy/…
-
toha almost 2 yearsso how to activate if the hostingmodel is inprocess sir?
-
Dmitry Pavlov almost 2 years@toha this should fo the trick
<PropertyGroup><AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel></PropertyGroup>
- see In-process hosting with IIS and ASP.NET Core