Skip to content

In Blazor server disconnects immediately after connecting to the web socket using state persisting. #10348

@mrj02

Description

@mrj02

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

On pages with InteractiveServer, when I persist state after connecting to the websocket, it immediately disconnects (according to experience, this error occurs when moving from an SSR
page to an InteractiveServer and does not occur when moving from an InteractiveServer to an InteractiveServer)

Image

This problem does not occur without persisting state.

  public interface IUsersExtraInfoApiDomain
  {
      Task<AddresApiResponce> GetLstUserAddress(string UserID);
  }

  public async Task<AddresApiResponce> GetLstUserAddress(string UserID)
  {
      await using var _MeroojDbContext = ContextFactory.CreateDbContext();
      AddresApiResponce Result = new AddresApiResponce();
      Result.Data = await _MeroojDbContext.Table_UserAddresses.Where(o => o.UserID == UserID).Select(o => new AddresObjectApiResponce()
      {
          CityID = o.CityID,
          FullAddress = o.FullAddress,
          LocationLat = o.LocationLat,
          LocationLong = o.LocationLong,
          Number = o.Number,
          Unit = o.Unit,
          ID= o.UserAddressID,
          Active= o.Active
      }).ToListAsync();
      Result.StatusCode = 200;


      return Result;
  }

private AddresApiResponce AddressResponce = new();

protected override async Task OnInitializedAsync()
{
   AddressResponce = await StateService.GetValue($"{nameof(AddressComponent)}-addressResponce", async () => await GetListUserAddress()) ?? new();
}

private async Task<AddresApiResponce> GetListUserAddress()
{
    return await UsersExtraInfoApi.GetLstUserAddress(UserId!);
}
// The injectables are in AppComponentBase .

Expected Behavior

No response

Steps To Reproduce

No response

Exceptions (if any)

No response

.NET Version

9.0.202

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions