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

Far*_*han 6 c# asp.net web-config code-behind httpruntime

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

有没有办法web.config通过C#设置值?

Muh*_*tar 3

是的,你可以在里面设置web.config

只需将其设置在web.config该部分的下方即可<system.web>。在下面的示例中,我将设置maximum length2GB

<httpRuntime maxRequestLength="2097152" executionTimeout="600" />
Run Code Online (Sandbox Code Playgroud)

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