c# - HttpException:超出最大请求长度,即使配置具有应允许的值
问题描述
我似乎不允许上传 4.3MB。我不断收到此错误:
System.Web.HttpException (0x80004005):超出最大请求长度。
我的 Web API 中的 web.config 设置:
<!-- maxRequestLength expresses POST buffer size in KB. This is the ASP.NET limit. -->
<httpRuntime targetFramework="4.5" maxRequestLength="20000" />
<!-- Let this be larger than maxRequestLength so we get ASP.NET error (if request too large) instead of IIS error. -->
<requestLimits maxAllowedContentLength="20480000" />
这是我的网络项目对 API 的调用:
var response = await httpClient.SendAsync(proxyRequest);
那总是返回上述错误。我错过了什么?我确实读过 wheremaxRequestLength
需要与 相同的值maxAllowedContentLength
,但这也不起作用。
解决方案
IIS 中的“默认网站”有一个配置文件,其中几乎没有任何内容。我添加maxRequestLength="20000"
了它并且它起作用了。我的应用是“默认网站”下的众多应用之一。
添加了这个:
<system.web>
<httpRuntime targetFramework="4.5" maxRequestLength="20000" />
</system.web>
推荐阅读
- javascript - 如何将 semanti-ui 连接到 nuxt.js
- scala - 如何将嵌套对象从 rdd 行转换为一些自定义对象
- html - 具有屏幕宽度标题、限制宽度内容、弹性框徽标元素和粘性页脚的 HTML 页面
- python - Python中有没有办法遍历完整的脚本?
- node.js - 如何配置 TypeORM ormconfig.json 文件以解析 js dist 文件夹或 ts src 文件夹中的实体?
- r - 两行中 x 轴的图例
- python - 为什么我使用 `exec()` 的代码会引发错误?
- bash - 如何在选择和测试函数中传递参数?
- python - 如何在没有附加功能的情况下将多个列值附加到单个列中?
- typeorm - 有没有办法(或最佳实践)与我的代码前端共享我的 TypeORM 模型而无需完全重复?