繁体   English   中英

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

[英]How to programmatically set (using GET SET property) “httpRuntime maxRequestLength” in ASP.NET with C# as code behind

如何以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();

我们在Rock RMS内容管理系统中做到这一点

是的,您可以在web.config设置

只需在<system.web>部分下的web.config进行设置即可。 在下面的示例中,我将maximum length设置为2GB

<httpRuntime maxRequestLength="2097152" executionTimeout="600" />

请注意, maxRequestLengthKB's为单位设置,最大可设置为2GB( 2079152 KB's )。 但是默认文件大小限制为(4MB)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM