﻿
{"id":12372,"date":"2019-11-01T22:05:29","date_gmt":"2019-11-01T22:05:29","guid":{"rendered":"https:\/\/www.gencayyildiz.com\/blog\/?p=12372"},"modified":"2019-11-01T22:05:29","modified_gmt":"2019-11-01T22:05:29","slug":"asp-net-core-3-0-web-api-mimarisinde-a-possible-object-cycle-was-detected-which-is-not-supported-hatasi-ve-cozumu","status":"publish","type":"post","link":"https:\/\/www.gencayyildiz.com\/blog\/asp-net-core-3-0-web-api-mimarisinde-a-possible-object-cycle-was-detected-which-is-not-supported-hatasi-ve-cozumu\/","title":{"rendered":"Asp.NET Core 3.0 Web API Mimarisinde &#8220;A Possible Object Cycle Was Detected Which Is Not Supported&#8221; Hatas\u0131 ve \u00c7\u00f6z\u00fcm\u00fc"},"content":{"rendered":"<div id=\"fb-root\"><\/div>\n<p>Merhaba,<\/p>\n<p>Asp.NET Core Web API 3.0 mimarisinde endpointlere yap\u0131lan istekler neticesinde JSON format\u0131na parse edilip g\u00f6nderilen veriler e\u011fer ki birbiriyle ili\u015fkisel verilerden ibaretse<span style=\"font-size:12px;\">(ki genellikle bu \u015fekilde ili\u015fkisel veriler <a href=\"https:\/\/www.gencayyildiz.com\/blog\/entity-framework-core-lazy-loading\/\" rel=\"noopener noreferrer\" target=\"_blank\">Entity Framework Core &#8211; Lazy Loading<\/a> mekanizmas\u0131 ile elde edilir)<\/span> bu parse i\u015flemi ger\u00e7ekle\u015ftirilemeyecek ve makalemizin ba\u015fl\u0131\u011f\u0131n\u0131da olu\u015fturan a\u015fa\u011f\u0131daki hatay\u0131 verecektir.<br \/>\n<a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/11\/Asp.NET-Core-3.0-Web-API-Mimarisinde-A-Possible-Object-Cycle-Was-Detected-Which-Is-Not-Supported-Hatas\u0131-ve-\u00c7\u00f6z\u00fcm\u00fc.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/11\/Asp.NET-Core-3.0-Web-API-Mimarisinde-A-Possible-Object-Cycle-Was-Detected-Which-Is-Not-Supported-Hatas\u0131-ve-\u00c7\u00f6z\u00fcm\u00fc.jpg\" alt=\"Asp.NET Core 3.0 Web API Mimarisinde A Possible Object Cycle Was Detected Which Is Not Supported Hatas\u0131 ve \u00c7\u00f6z\u00fcm\u00fc\" width=\"1428\" height=\"419\" class=\"aligncenter size-full wp-image-12380\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/11\/Asp.NET-Core-3.0-Web-API-Mimarisinde-A-Possible-Object-Cycle-Was-Detected-Which-Is-Not-Supported-Hatas\u0131-ve-\u00c7\u00f6z\u00fcm\u00fc.jpg 1428w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/11\/Asp.NET-Core-3.0-Web-API-Mimarisinde-A-Possible-Object-Cycle-Was-Detected-Which-Is-Not-Supported-Hatas\u0131-ve-\u00c7\u00f6z\u00fcm\u00fc-300x88.jpg 300w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/11\/Asp.NET-Core-3.0-Web-API-Mimarisinde-A-Possible-Object-Cycle-Was-Detected-Which-Is-Not-Supported-Hatas\u0131-ve-\u00c7\u00f6z\u00fcm\u00fc-768x225.jpg 768w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/11\/Asp.NET-Core-3.0-Web-API-Mimarisinde-A-Possible-Object-Cycle-Was-Detected-Which-Is-Not-Supported-Hatas\u0131-ve-\u00c7\u00f6z\u00fcm\u00fc-1024x300.jpg 1024w\" sizes=\"auto, (max-width: 1428px) 100vw, 1428px\" \/><\/a><\/p>\n<p>Hatay\u0131 metinsel olarak da a\u015fa\u011f\u0131da ele alal\u0131m&#8230;<\/p>\n<blockquote><p><strong><em style=\"font-size:14px;color:green;\">System.Text.Json.JsonException: A possible object cycle was detected which is not supported. This can either be due to a cycle or if the object depth is larger than the maximum allowed depth of 32.<\/em><\/strong><\/p><\/blockquote>\n<p>Bu hata ili\u015fkisel verilerin serialize edilmesinde d\u00f6ng\u00fcsel durumun ger\u00e7ekle\u015ftirilememesinden kaynaklanmaktad\u0131r. Dolay\u0131s\u0131yla bu duruma \u00e7\u00f6z\u00fcm olarak .NET Core 3.0&#8217;da json politikalar\u0131 de\u011fi\u015ftirildi ve serialize becerisi olduk\u00e7a g\u00fc\u00e7lendirildi. Hatay\u0131 \u00e7\u00f6zebilmek i\u00e7in <a href=\"https:\/\/www.nuget.org\/packages\/Microsoft.AspNetCore.Mvc.NewtonsoftJson\/\" rel=\"noopener noreferrer\" target=\"_blank\">Microsoft.AspNetCore.Mvc.NewtonsoftJson<\/a> k\u00fct\u00fcphanesini uygulaman\u0131za eklemeniz ve ard\u0131ndan Startup dosyas\u0131nda a\u015fa\u011f\u0131daki operasyonu ger\u00e7ekle\u015ftirmeniz gerekmektedir.<br \/>\n<a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/11\/Asp.NET-Core-3.0-Web-API-Mimarisinde-A-Possible-Object-Cycle-Was-Detected-Which-Is-Not-Supported-Hatas\u0131-ve-\u00c7\u00f6z\u00fcm\u00fc-1.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/11\/Asp.NET-Core-3.0-Web-API-Mimarisinde-A-Possible-Object-Cycle-Was-Detected-Which-Is-Not-Supported-Hatas\u0131-ve-\u00c7\u00f6z\u00fcm\u00fc-1.jpg\" alt=\"Asp.NET Core 3.0 Web API Mimarisinde A Possible Object Cycle Was Detected Which Is Not Supported Hatas\u0131 ve \u00c7\u00f6z\u00fcm\u00fc\" width=\"1162\" height=\"459\" class=\"aligncenter size-full wp-image-12400\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/11\/Asp.NET-Core-3.0-Web-API-Mimarisinde-A-Possible-Object-Cycle-Was-Detected-Which-Is-Not-Supported-Hatas\u0131-ve-\u00c7\u00f6z\u00fcm\u00fc-1.jpg 1162w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/11\/Asp.NET-Core-3.0-Web-API-Mimarisinde-A-Possible-Object-Cycle-Was-Detected-Which-Is-Not-Supported-Hatas\u0131-ve-\u00c7\u00f6z\u00fcm\u00fc-1-300x119.jpg 300w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/11\/Asp.NET-Core-3.0-Web-API-Mimarisinde-A-Possible-Object-Cycle-Was-Detected-Which-Is-Not-Supported-Hatas\u0131-ve-\u00c7\u00f6z\u00fcm\u00fc-1-768x303.jpg 768w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2019\/11\/Asp.NET-Core-3.0-Web-API-Mimarisinde-A-Possible-Object-Cycle-Was-Detected-Which-Is-Not-Supported-Hatas\u0131-ve-\u00c7\u00f6z\u00fcm\u00fc-1-1024x404.jpg 1024w\" sizes=\"auto, (max-width: 1162px) 100vw, 1162px\" \/><\/a><\/p>\n<p>Yukar\u0131daki ekran g\u00f6r\u00fcnt\u00fcs\u00fcnde de g\u00f6rebildi\u011finiz gibi &#8220;AddControllers()&#8221; metodunun devam\u0131na &#8220;AddNewtonsftJson(..)&#8221; metodu eklenmekte ve i\u00e7erisine parametre olarak json operasyonlar\u0131na \u00f6zel gerekli konfig\u00fcrasyonel i\u015flemleri yapt\u0131\u011f\u0131m\u0131z lambda ifadesi olu\u015fturulmakta ve ili\u015fkisel nesnelerdeki d\u00f6ng\u00fcsel durumlar\u0131n i\u015flenmesi g\u00f6rmezden gelinmektedir.<\/p>\n<p>Ve bu \u015fekilde hata ortadan kald\u0131r\u0131lm\u0131\u015f bulunmaktad\u0131r&#8230;<\/p>\n<p>\u0130lgilenenlerin ve \u015fifa aray\u0131nlar\u0131n faydalanmas\u0131 dile\u011fiyle&#8230; \ud83d\ude42<br \/>\nSonraki yaz\u0131lar\u0131mda g\u00f6r\u00fc\u015fmek \u00fczere&#8230;<br \/>\n\u0130yi \u00e7al\u0131\u015fmalar&#8230;<\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>Merhaba, Asp.NET Core Web API 3.0 mimarisinde endpointlere yap\u0131lan istekler neticesinde JSON format\u0131na parse edilip g\u00f6nderilen veriler e\u011fer ki birbiriyle ili\u015fkisel verilerden ibaretse(ki genellikle bu \u015fekilde ili\u015fkisel veriler Entity Framework Core &#8211; Lazy Loading&#46;&#46;&#46;<!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":1,"featured_media":3014,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3033,2898],"tags":[3050,2891,3049,1083],"class_list":["post-12372","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-net-core-3-0","category-asp-net-core-3-0","tag-net-core-3-0-hatasi","tag-asp-net-core-3-0","tag-asp-net-core-3-0-hatasi","tag-hata-ve-cozumu"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/posts\/12372","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/comments?post=12372"}],"version-history":[{"count":27,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/posts\/12372\/revisions"}],"predecessor-version":[{"id":12402,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/posts\/12372\/revisions\/12402"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/media\/3014"}],"wp:attachment":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/media?parent=12372"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/categories?post=12372"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/tags?post=12372"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}