我使用 fiddler 来调用我的方法,对于小字符串,它工作得很好。但是,我的输入参数可能是 250 MB 文件的内容。
我是这样称呼它的:
POST
http://localhost:23234/api/myfiles
User-Agent: Fiddler
Host: localhost:23234
Content-Type: application/json
Content-Length: 317210
Run Code Online (Sandbox Code Playgroud)
在请求正文部分,我有一个有 5.000 行的文件的内容。
该方法没有受到打击。相反,我收到错误 500,错误消息是:Uri 字符串太长。
我能做些什么来完成这项工作?
如果您在 IIS 中托管您的 API,您应该通过将以下内容添加到您的 web.config 来增加允许的最大请求大小(默认为 4MB):
<system.web>
<!-- The value is in KB -->
<httpRuntime maxRequestLength="1048576" />
</system.web>
Run Code Online (Sandbox Code Playgroud)
如果您使用的是集成管道模式:
<system.webServer>
<security>
<requestFiltering>
<!-- The value is in bytes -->
<requestLimits maxAllowedContentLength="1073741824" />
</requestFiltering>
</security>
</system.webServer>
Run Code Online (Sandbox Code Playgroud)
这将允许发送 1GB 的请求。
此外,您似乎已将 设置为Content-Type,application/json因此您应该确保发布有效的 JSON 有效负载。最后但并非最不重要的一点是,确保您在 Fiddler 组合框中选择了带有动词的 POST(默认为 GET)。
| 归档时间: |
|
| 查看次数: |
2301 次 |
| 最近记录: |