使用asp.net在webconfig中放大上传的文件大小



我的情况是,当我上传大小超过4mb的文件时,我想向用户显示一条友好的消息,但当我超过这个限制时,它不会给我带来错误,而是会把我带到:

  Internet Explorer cannot display the webpage 

我检查文件大小的方法是这样的:

   if (FU_EnglishFile.PostedFile.ContentLength > int.Parse(ConfigurationManager.AppSettings["MaxUploadSize"]))
                            {
                                lbl_InvalidFileMsg.Visible = true;
                                return;
                            }
                            else
                            {
                                lbl_InvalidFileMsg.Visible = false;
}

web配置中的文件大小为:

 <add key="MaxUploadSize" value="4194304" />

我是否应该在web配置中设置任何配置或任何有帮助的东西?

请使用上面的代码来获得较小的大小,如3MB,然后检查结果。

我找到了这个问题的答案:

请在网络配置中设置此标签

  <system.web>
    <httpRuntime executionTimeout="240" maxRequestLength="20480" />
 </system.web>

感谢

最新更新