加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

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

发布时间:2020-12-16 06:53:24 所属栏目:asp.Net 来源:网络整理
导读:我一直在收到“连接强行关闭”错误,在研究解决方案时,我看到了以下web.config选项的建议,这些选项目前未在我的网络应用中设置. 在我改变它们之前,我想知道它们目前的用途. 有人可以告诉我如何从.NET代码中读取这些值,最好是VB.NET,尽管C#很好. httpRuntime e
我一直在收到“连接强行关闭”错误,在研究解决方案时,我看到了以下web.config选项的建议,这些选项目前未在我的网络应用中设置.

在我改变它们之前,我想知道它们目前的用途.

有人可以告诉我如何从.NET代码中读取这些值,最好是VB.NET,尽管C#很好.

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

解决方法

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

以下代码将以programitcly的形式打开httpRuntime部分

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;

根据评论进行编辑.

从MSDN调用WebConfigurationManager.OpenWebConfiguration时

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.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读