webApi parameters data-length

人走茶凉 提交于 2020-01-03 02:29:12

问题


How can I configurate WebApi Controller to read all data that passed in as a parameter?

Client:

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

Controller:

 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;
        }
 }

in HttpContext I see that all data received.


回答1:


Form Url Encoded Formatter doesn't want to read confoguration from
httpRuntime maxRequestLength="80000000", so in global.asax:

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


来源:https://stackoverflow.com/questions/10229235/webapi-parameters-data-length

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!