How to programmatically set (using the GET SET property) "httpRuntime maxRequestLength" in ASP.NET with C # as the code for
is there any way to set values in web.configvia c #?
web.config
You can set the web.config maxRequestLength property in the code as follows:
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();
We do this exact thing in our Rock RMS content management system.
Yes, you can set it to web.config
web.config <system.web>. maximum length 2GB
<system.web>
maximum length
2GB
<httpRuntime maxRequestLength="2097152" executionTimeout="600" />
, maxRequestLength KB's, 2 (2079152 KB's). - (4MB).
maxRequestLength
KB's
2079152 KB's
(4MB)