1

如何配置 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 我看到收到的所有数据。

4

1 回答 1

1

Form Url Encoded Formatter 不想从
httpRuntime maxRequestLength="80000000" 读取配置,所以在 global.asax 中:

  public static void Configure(HttpConfiguration conf)
    {
        conf.Formatters.FormUrlEncodedFormatter.ReadBufferSize = int.MaxValue/10;
    }
于 2012-04-20T06:48:21.427 回答