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

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

问题描述

有没有办法从 C# 中设置 requestTimeout 而不是需要在 web.config 中设置 requestTimeout?

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

ASP.NET Core 2.0 托管在 IIS 中

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=".logsstdout" />
  </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 Module 并移至已发布的输出.该转换不会修改文件中的 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天全站免登陆