的WebAPI参数数据长度(webApi parameters data-length)

2019-09-16 15:12发布

我怎样才能configurate的WebAPI控制器来读取传过来的参数的所有数据?

客户:

  $.post(url,{id:aHugeData});

控制器:

 public class myController : ApiController
  {
   public List<string> Events(List<Event> id) //there must be 30 items, but I see 7
        {
            List<string> artists = new List<string>();
            foreach (Event e in id)
            {
                artists.AddRange(e.artists.artist);
            }
            artists = artists.Distinct().ToList();

            return artists;
        }
 }

在HttpContext的我看到,接收的所有数据。

Answer 1:

表URL编码格式化并不想读取confoguration
的httpRuntime的maxRequestLength = “80000000”,所以在global.asax中:

  public static void Configure(HttpConfiguration conf)
    {
        conf.Formatters.FormUrlEncodedFormatter.ReadBufferSize = int.MaxValue/10;
    }


文章来源: webApi parameters data-length