可以通过C#代码在IIS托管的asp.net core 2.0中设置请求超时吗? [英] Can you set request timeout in asp.net core 2.0 hosted in IIS from C# code?

查看:241
本文介绍了可以通过C#代码在IIS托管的asp.net core 2.0中设置请求超时吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以通过C#设置 requestTimeout ,而无需在<$ c $中设置 requestTimeout c> web.config ?

Is there a way to set requestTimeout from C# instead of needing to set requestTimeout in the web.config?

在IIS中托管的ASP.NET Core 2.0

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>

不像这样

推荐答案

不,您无法做到 。但是根据文档 ,您只需将web.config添加到您的项目中,然后指定此(和其他)设置值即可:

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:


如果项目中没有 web.config 文件,则将创建
文件具有正确的processPath和参数来配置ASP.NET
核心模块并移至已发布的输出。

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.

如果 web.config 文件存在于项目中,该文件已通过正确的processPath和参数对
进行了转换,以配置
ASP。 NET Core Modul e并移至已发布的输出。
转换不会修改文件中的IIS配置设置

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.

web.config 文件可能会提供其他 IIS 配置设置
,用于控制活动的 IIS 模块。有关 IIS 模块上
能够使用 ASP.NET Core 应用程序处理请求的信息,请参阅 IIS
模块主题。

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.

要防止Web SDK转换web.config文件,请使用项目文件中的
IsTransformWebConfigDisabled 属性。

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

这篇关于可以通过C#代码在IIS托管的asp.net core 2.0中设置请求超时吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆