webApi参数数据长度

时间:2012-04-19 13:34:41

标签: asp.net-mvc asp.net-mvc-4 asp.net-web-api

如何配置Web Api Controller以读取作为参数传入的所有数据?

客户端:

  $.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中我看到收到的所有数据。

1 个答案:

答案 0 :(得分:1)

表单URL编码格式化程序不希望从中读取混淆   httpRuntime maxRequestLength =“80000000”,所以在global.asax:

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