My application is an ASP.NET Core 1.0 Web API.
If my Controller Returns a small JSON, everything works fine. However, if the JSON gets bigger, I am getting this error
Visual Studio is giving me this error
This is the Controller and the Method that creates the Data (shortened)
[HttpGet]
public async Task<IActionResult> GetUserData()
{
return this.Ok(GetSomeData());
}
private List<MyUser> GetSomeData()
{
var userList = new List<MyUser>();
for (int i = 0; i < 2500; i++)
{
userList.Add(new MyUser{
Name = "Data",
Age = i,
Phone = "000",
});
}
return userList;
}
If the loop is getting to big, Iam getting the errors listed above.
Keep in mind that the code is extremely simplified. But everything works fine, until to much data is returned.
I have tried to change the maxJsonLength
in the web.config
as it's described here.