ASP.NET MVC Web.config maxRequestLength似乎被忽略了

时间:2015-09-03 17:04:01

标签: c# asp.net-mvc iis

我正在尝试更改我的本地IIS服务器上的ASP.NET MVC应用程序的最大上载文件大小。我正在使用IE 11来运行该应用程序。

最终,我希望最大上传文件大小仅适用于某些页面。不过,就目前而言,我只是想让它在整个网站上运行,看起来我正在尝试设置的值被忽略。

在Webconfig.cs中,我把它放在以下部分:

<system.web>
    <httpRuntime executionTimeout="360" maxRequestLength="100000" />
</system.web>

当我检查控制器中的最大请求长度的值时,我仍然得到4 MB(IIS默认值):

System.Configuration.Configuration config = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~");
System.Web.Configuration.HttpRuntimeSection section = config.GetSection("system.web/httpRuntime") as System.Web.Configuration.HttpRuntimeSection;
double maxFileSize = Math.Round(section.MaxRequestLength / 1024.0, 1);

我错过了什么?

0 个答案:

没有答案
相关问题