[英]ASP.NET C# Set OnSelectedIndexChanged from Code Behind
[英]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();
是的,您可以在web.config
设置
只需在<system.web>
部分下的web.config
进行设置即可。 在下面的示例中,我将maximum length
设置为2GB
<httpRuntime maxRequestLength="2097152" executionTimeout="600" />
请注意, maxRequestLength
以KB's
为单位设置,最大可设置为2GB( 2079152 KB's
)。 但是默认文件大小限制为(4MB)
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.