对于自托管的ASP.Net Web API请求实体太大

Vin*_*Vin 13 c# json xmlhttprequest asp.net-web-api

我有一大块json需要发布到自托管的ASP.Net Web API服务.

我收到" 状态代码:413请求实体太大 "消息.

试图将以下内容放在webapi服务项目的app.config中.

<system.web>
    <compilation debug="true" targetFramework="4.0" />
    <customErrors mode="Off"/>
    <httpRuntime
        maxRequestLength="2147483647"
        executionTimeout="300" />
</system.web>
Run Code Online (Sandbox Code Playgroud)

这没有用.

我正在考虑以下两个选项.

  1. 可能使用LZW压缩库解压缩javascript中的数据,并在接收后在webapi端解码.
  2. 找到一种方法来允许webapi基础架构允许大量数据

我更喜欢第二种选择,但尚未找到如何实现它.

有什么指针吗?

Bra*_*don 16

我遇到了同样的问题,并且能够在代码中进行更改.

var config = new HttpSelfHostConfiguration(host);
config.MaxReceivedMessageSize = 2147483647; // use config for this value
/*
other setup for the config
*/
using (var server = new HttpSelfHostServer(config))
{
    server.OpenAsync().Wait();
    Console.WriteLine("Insight.Web");
    Console.ReadLine();
}
Run Code Online (Sandbox Code Playgroud)