2

I have a standard .NET Core API Controller that returns JSON.

All works as designed but with larger data sets the response is being truncated.

I cannot work out (or find on Stack Overflow or elsewhere) how to increase the limit - presuming this is the cause.

Can someone point me in the right direction please?

5
  • did you try to setup maxJsonLength in web.config? stackoverflow.com/a/1151993/2833802 and maybe stackoverflow.com/a/3853785/2833802 Commented Jul 1, 2016 at 12:30
  • I did try that. May have got a typo or something so will try again Commented Jul 1, 2016 at 12:32
  • Which version of MVC package are you using? Commented Jul 1, 2016 at 14:54
  • 1
    @Set: Question is about ASP.NET Core, the linked answer is for legacy ASP.NET which also uses web.config as settings file. Commented Jul 1, 2016 at 15:44
  • @MarkChidlow, Could you use the Fiddler to trace your result? And Would you like to share your json result size ? Commented Jul 18, 2016 at 6:55

1 Answer 1

1

I had a similar issue and what seemed to fix it was setting the 'ReferenceLoopHandling' JSON setting:

public void ConfigureServices(IServiceCollection services)
{
        services.AddMvc().AddJsonOptions(options => {
            options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
        });
 ...
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.