Wishlist 0 ¥0.00

IIS WebApi: 文件上传,大小限制,提示413 (Request Entity Too Large)

我想如果有人按照我的标题搜结果,都是在linux系统上解决方案,或者是java。你是不是很绝望。我懂~

若你是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,找到文件上传的项目,选中->功能试图->配置编辑器(如下图)

1_p67039

 

 ② 修改两处(httpRuntime、requestLimits )

2_p43723

 

 

3_p50694

以上就可以解决文件过大无法上传这个问题。

About Us

Since 1996, our company has been focusing on domain name registration, web hosting, server hosting, website construction, e-commerce and other Internet services, and constantly practicing the concept of "providing enterprise-level solutions and providing personalized service support". As a Dell Authorized Solution Provider, we also provide hardware product solutions associated with the company's services.
 

Contact Us

Address: No. 2, Jingwu Road, Zhengzhou City, Henan Province

Phone: 0086-371-63520088 

QQ:76257322

Website: 800188.com

E-mail: This email address is being protected from spambots. You need JavaScript enabled to view it.