Reputation: 1287
I have a Asp.Net Core API v5.0.7. The client is a ReactJs.Net app.
All my controllers are marked with:
[Consumes("application/json")]
[Produces("application/json")]
My Startup.cs file ConfigureServices
method contains:
services.AddControllers()
.AddNewtonsoftJson(options => {
options.SerializerSettings.MaxDepth = 2;
options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
});
But I am still getting my json back with full depth:
[
{
"itemNumber": "11BRC",
"itemDescription": "Flat head Phillips Wood screw C-Pak 2x1/4",
"featured": false,
"categoryName": "Screws",
"category": {
"categoryId": 1003,
"parentId": 3056,
"name": "Screws",
"parent": {
"categoryId": 3056,
"parentId": 0,
"name": "Fasteners",
"parent": null,
"children": [
{
"categoryId": 3036,
"parentId": 3056,
"name": "Nuts",
"children": null,
"title": "Nuts",
"description": "Fastener Nuts",
"keywords": " Anchor, cage, classic, clinch, castle,nuts",
"pageContent": "<span style=\"font-style:italic; font-weight:bold; font-size:16pt;\"><span style=\"color:Blue; border-color:Blue; font-style:normal;\">NUTS</span><br/>Nuts and bolts are among the most expansive categories of hardware</span>. <br/>Options run the gamut, with coupling, locking, flanged, hex, square and more. We offer numerous material, finish and size options. When it comes to industrial nuts and bolts, <br/><span style=\"color:Navy; border-color:Navy; font-weight:bold;\">Fastener Superstore has a comprehensive selection for your manufacturing or assembly needs. We provide products in bulk so that your business is stocked with reliable, well made fasteners. When it comes to the hardware you use, it always pays to do business with the best.</span>",
"bannerGroupId": 0,
"inactive": 0,
"issitecategory": 0,
...
Do I need to add [JsonIgnore]
to my navigation properties?
Upvotes: 0
Views: 183