首页 > 技术文章 > .NET Framework webAPI上传文件大小限制

qtiger 2020-10-23 11:28 原文

提供给小程序的接口接收不了大文件参数,即便是使用post也不行,emmm,我这边采用的是[FromBody]接收参数,先来看下接口:

[HttpPost]
public HttpResponseMessage Upload([FromBody] string fileBase64)
{           
}

原本以为是文件太大,前端限制,没有传过来,后来想了想,还是先从自己这边找找解决方案吧,中间曲折的过程就不谈了,原因就是后端接口无法接收这么大的参数,直接说下解决方法,找到web.config,加句配置即可,emmm,好简单

<system.web> <httpRuntime targetFramework="4.5" maxQueryStringLength="102400" maxRequestLength="102400" maxUrlLength="102400" />

 


 

note:看了看文档,说是在web.config配置文件中的<system.webServer>节点中做配置也行,我没试,有兴趣的可以试下

<system.webServer> <security> <requestFiltering> <requestLimits maxAllowedContentLength="" maxQueryString="" maxUrl=""/>

 

推荐阅读