gpt4 book ai didi

asp.net - 如何确定以下默认 Web 配置值?

转载 作者:行者123 更新时间:2023-12-05 00:06:47 30 4
gpt4 key购买 nike

我一直收到“连接强行关闭”错误,在研究解决方案时,我看到了以下 web.config 选项的金钱建议,这些选项目前未在我的 Web 应用程序中设置。

在我更改它们之前,我想知道它们当前的设置。

有人能告诉我如何从 .NET 代码中读取这些值,最好是 VB.NET,虽然 C# 很好。

<httpRuntime 
executionTimeout="90"
maxRequestLength="4096"
useFullyQualifiedRedirectUrl="false"
minFreeThreads="8"
minLocalRequestFreeThreads="4"
appRequestQueueLimit="100"
/>

最佳答案

这是MSDN列出每个值及其默认值的页面。

下面的代码将打开 httpRuntime 部分 programitcly

Configuration config = WebConfigurationManager.OpenWebConfiguration("~");
object o = config.GetSection("system.web/httpRuntime");
HttpRuntimeSection section = o as HttpRuntimeSection;

找到此代码 here

而在 VB 中
Dim config As Configuration = WebConfigurationManager.OpenWebConfiguration("~")
Dim o As Object = config.GetSection("system.web/httpRuntime")
Dim section As HttpRuntimeSection = TryCast(o, HttpRuntimeSection)

确保您正在使用/导入以下命名空间。
System.Configuration;
System.Web.Configuration;

根据评论进行编辑。

打电话时 WebConfigurationManager.OpenWebConfiguration来自 MSDN

path Type: System.String The virtual path to the configuration file. If null, the root Web.config file is opened.



即使您没有在 web.config 中定义 httpRuntime,它也是根 Web.config,并且会返回。我已经在定义和未定义 httpRuntime 的情况下对此进行了测试。

关于asp.net - 如何确定以下默认 Web 配置值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2858951/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com