我有一个Asp.Net Core v5.0.7。客户端是一个ReactJs.Net应用程序。
我所有的控制器都有以下标记:
[Consumes("application/json")]
[Produces("application/json")]我的Startup.cs文件ConfigureServices方法包含:
services.AddControllers()
.AddNewtonsoftJson(options => {
options.SerializerSettings.MaxDepth = 2;
options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
});但我还是要让我的儿子更有深度:
[
{
"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,
...是否需要将[JsonIgnore]添加到导航属性中?
发布于 2021-07-09 17:34:12
解决方案:我用AutoMapper将所有东西都压平为dto
https://stackoverflow.com/questions/68303166
复制相似问题