gpt4 book ai didi

c# - 如何以编程方式设置(使用 GET SET 属性) "httpRuntime maxRequestLength"在 ASP.NET 中使用 C# 作为代码隐藏

转载 作者:太空狗 更新时间:2023-10-29 21:36:05 25 4
gpt4 key购买 nike

如何使用 C# 作为代码在 ASP.NET 中以编程方式设置(使用 GET SET 属性)“httpRuntime maxRequestLength”

有什么方法可以通过 C# 在 web.config 中设置值吗?

最佳答案

您可以设置 web.config 的 maxRequestLength代码中的属性如下:

Configuration webConfig = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration( "~" );
var section = (System.Web.Configuration.SystemWebSectionGroup)webConfig.GetSectionGroup("system.web");
section.HttpRuntime.MaxRequestLength = 10 * 1024; // 10 MB
webConfig.Save();

我们做 this exact thing在我们的 Rock RMS内容管理系统。

关于c# - 如何以编程方式设置(使用 GET SET 属性) "httpRuntime maxRequestLength"在 ASP.NET 中使用 C# 作为代码隐藏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6888688/

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