Can you set request timeout in asp.net core 2.0 hosted in IIS from C# code?

核能气质少年 提交于 2019-12-07 03:14:41

问题


Is there a way to set requestTimeout from C# instead of needing to set requestTimeout in the web.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>

Not like this


回答1:


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 the ASP.NET Core Module and moved to published output. The transformation doesn't modify IIS configuration settings in the file.

The web.config file may provide additional IIS configuration settings that control active IIS modules. For information on IIS modules that are capable of processing requests with ASP.NET Core apps, see the IIS modules topic.

To prevent the Web SDK from transforming the web.config file, use the IsTransformWebConfigDisabled property in the project file.



来源:https://stackoverflow.com/questions/50210876/can-you-set-request-timeout-in-asp-net-core-2-0-hosted-in-iis-from-c-sharp-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!