c#程序 上传文件大小限制

https://www.cnblogs.com/pukua/p/12598091.html

若你是C#研发,其实这个问题的解决方向在IIS上,所以你去搜“IIS 设置文件上传大小限制设置方法”,就会有一堆你想要的答案。我就不贴了。

 

net(C#)项目:当你想要上传时,文件过大,报413时,有两种解决方案,这两种解决方案任选其一就可以

一、在web.config上配置,按照以下格式,将下列标红加粗的地方,按照对应位置复制到web.config中,即可解决。

注:这两个标红处均要复制,配置!!!

    httpRuntime 中 maxRequestLength就是设置你上传文件的大小限制;
    requestLimits 中 maxAllowedContentLength就是设置你上传文件的大小限制;
 
<configuration> <system.web> <compilation targetFramework="4.6.1" /> <httpRuntime executionTimeout="600" maxRequestLength="419430400" targetFramework="4.6.1" /> </system.web> <system.webServer> <security> <requestFiltering> <requestLimits maxAllowedContentLength="419430400" /> </requestFiltering> </security> </system.webServer> </configuration>
 

二、IIS中配置

① 打开IIS,找到文件上传的项目,选中->功能试图->配置编辑器(如下图)

 

 ② 修改两处(httpRuntime、requestLimits )

 

https://blog.csdn.net/yaoyaoopen/article/details/9241569?utm_medium=distribute.pc_relevant.none-task-blog-baidujs_title-4&spm=1001.2101.3001.4242

 

posted @ 2021-05-19 16:01  哇咔咔,啊哈哈  阅读(1117)  评论(0)    收藏  举报