JSON causing site to disconnect

Is there something special I should know about when dealing with a JSON string? I have a page with a textbox (code below) and a button. The user pastes the JSON string into the textbox, but when they click the button, the site disconnects. If they paste any non-JSON text into the textbox, it works fine. What am I missing?

Thank you so much

@using PricingModel.Entity
@using System.Text;
@inject IJSRuntime JSRuntime
@inject Radzen.DialogService dialogService

@if (!string.IsNullOrEmpty(pageError))
{

@((MarkupString)pageError)

}

@if (!string.IsNullOrEmpty(ReturnData?.TheRequest?.SelectedUtility?.UtilityName)) {
@((MarkupString)GetPageMessage())
}

@code {
[CascadingParameter] public CascadingAppState AppState { get; set; }
private string pageError = string.Empty;
string JSONString = string.Empty;
private CalculationEntity ReturnData = new();
private void ClosePopup()
{
if (string.IsNullOrEmpty(pageError))
{ dialogService.Close(ReturnData); }
else
{ dialogService.Close(false); }
}
private void LoadJSON()
{
try
{
pageError = string.Empty;
ReturnData = DataFactory.Code.SerializationFactory.RehydrateJSONToCalculationEntity(JSONString);
}
catch (Exception ex)
{
pageError = ex.Message;
}
}
private string GetPageMessage()
{
return "1 request loaded for " + ReturnData?.TheRequest?.SelectedUtility?.UtilityName + ", " + ReturnData?.TheRequest?.WholesaleZone;
}
}

I don't see any textbox in the provided code. Please format it according to our forum FAQ - it is quite unreadable at the moment.

Sorry. Here you go:

@using PricingModel.Entity
@using System.Text;
@inject IJSRuntime JSRuntime
@inject Radzen.DialogService dialogService

@if (!string.IsNullOrEmpty(pageError))
{
    <div class="alert alert-danger">@((MarkupString)pageError)</div>
}
<div class="row">
    <div class="col-sm-6">
        <RadzenTextBox Placeholder="Paste Usage..." @bind-Value="JSONString" class="form-control"/>
    </div>
    <div class="col-sm-6">
        @if (!string.IsNullOrEmpty(ReturnData?.TheRequest?.SelectedUtility?.UtilityName))
        {
            <div class="alert alert-success">@((MarkupString)GetPageMessage())</div>
            <RadzenButton Icon="close" Text="Send To Main" title="Send To Main" Click="() => ClosePopup()" class="btn-default rounded-pill" Style="float:right" />
        }
    </div>
</div>
<RadzenButton Icon="save" Text="Load JSON" title="Load JSON" Click="() => LoadJSON()" class="btn btn-success rounded-pill" Style="float:left" />


@code {
    [CascadingParameter] public CascadingAppState AppState { get; set; }
    private string pageError = string.Empty;
    string JSONString = string.Empty;
    private CalculationEntity ReturnData = new();
    private void ClosePopup()
    {
        if (string.IsNullOrEmpty(pageError))
        { dialogService.Close(ReturnData); }
        else
        { dialogService.Close(false); }
    }
    private void LoadJSON()
    {
        try
        {
            pageError = string.Empty;
            ReturnData = DataFactory.Code.SerializationFactory.RehydrateJSONToCalculationEntity(JSONString);
        }
        catch (Exception ex)
        {
            pageError = ex.Message;
        }
    }
    private string GetPageMessage()
    {
        return "1 request loaded for " + ReturnData?.TheRequest?.SelectedUtility?.UtilityName + ", " + ReturnData?.TheRequest?.WholesaleZone;
    }
}

The code looks correct. What happens when you debug the application?

It doesn't even hit the break point. The browser error just says it was disconnected:
[2024-05-10T05:58:35.449Z] Error: Connection disconnected with error 'Error: Server returned an error on close: Connection closed with an error.'.

Maybe the payload is too big - you can try increasing it or test with smaller JSON strings.. In any case doesn't seem caused by or related to the Radzen.Blazor components.

I will try that. Thank you