Open Closed

Internal Error in External Login #9626


User avatar
0
jlanza10 created

EXCEPTION: 2025-07-17 11:30:13.161 +00:00 [ERR] ---------- RemoteServiceErrorInfo ---------- { "code": null, "message": "InternalServerErrorMessage", "details": null, "data": {}, "validationErrors": null }

2025-07-17 11:30:13.162 +00:00 [ERR] A possible object cycle was detected. This can either be due to a cycle or if the object depth is larger than the maximum allowed depth of 64. Consider using ReferenceHandler.Preserve on JsonSerializerOptions to support cycles. Path: $.Principal.Claims.Subject.Claims.Subject.Claims.Subject.Claims.Subject.Claims.Subject.Claims.Subject.Claims.Subject.Claims.Subject.Claims.Subject.Claims.Subject.Claims.Subject.Claims.Subject.Claims.Subject.Claims.Subject.Claims.Subject.Claims.Subject.Claims.Subject.Claims.Subject.Claims.Subject.Claims.Subject.Claims.Issuer. System.Text.Json.JsonException: A possible object cycle was detected. This can either be due to a cycle or if the object depth is larger than the maximum allowed depth of 64. Consider using ReferenceHandler.Preserve on JsonSerializerOptions to support cycles. Path: $.Principal.Claims.Subject.Claims.Subject.Claims.Subject.Claims.Subject.Claims.Subject.Claims.Subject.Claims.Subject.Claims.Subject.Claims.Subject.Claims.Subject.Claims.Subject.Claims.Subject.Claims.Subject.Claims.Subject.Claims.Subject.Claims.Subject.Claims.Subject.Claims.Subject.Claims.Subject.Claims.Subject.Claims.Issuer.

I found this support ticket https://abp.io/support/questions/8143/A-cycle-during-the-cache-serialization but is not clear how to configure it.

Could you attach an example please?


5 Answer(s)
  • User Avatar
    0
    AI-Bot created
    Support Team ABP Agent

    To resolve the "A possible object cycle was detected" error during external login in ABP, you need to configure the JSON serializer to handle object cycles. In .NET, this is typically done by setting ReferenceHandler.Preserve on JsonSerializerOptions. In ABP Blazor WASM projects, you can configure this globally for your application.

    Here is an example of how to configure the JSON serializer to use ReferenceHandler.Preserve in your Blazor WASM project:

    1. Configure in Program.cs (Blazor WASM Client):

    using System.Text.Json; using System.Text.Json.Serialization;

    builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });

    builder.Services.Configure

    
    2. **Configure in Startup (Server Side, if applicable):**
    
       If you have a server-side (API) project, configure the JSON options in `Startup.cs` or `Program.cs`:
    
       ```csharp
    services.AddControllers()
           .AddJsonOptions(options =>
           {
               options.JsonSerializerOptions.ReferenceHandler = ReferenceHandler.Preserve;
               options.JsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.CamelCase;
           });
    
    1. Restart your application after making these changes.

    This configuration will allow the serializer to handle object cycles and prevent the exception you encountered.

    Sources:


    This response was generated by AI. If it didn’t solve your problem, feel free to post a new answer — our support team will jump in to help you soon.

  • User Avatar
    0
    jlanza10 created

    In the Program.cs of blazor client or in my host module?

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Could you please share the code that reproduces this exception?

    Thanks.

  • User Avatar
    0
    jlanza10 created

    We cannot share that code because is our enterprise production code. As i said we've seen this closed ticket https://abp.io/support/questions/8143/A-cycle-during-the-cache-serialization so we guess that the solution for it will do, we only need how to configure it exactly.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    we only need how to configure it exactly.

    You need to configure JSON options in two places.

    
    // This is for MVC JsonSerializer
    Configure<JsonOptions>(options =>
    {
        options.
    });
    
    
    // This is for ABP JsonSerializer
    Configure<AbpSystemTextJsonSerializerOptions>(options =>
    {
        options.
    });
    
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.0.0-preview. Updated on September 01, 2025, 08:37