bitplatform icon indicating copy to clipboard operation
bitplatform copied to clipboard

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

Open mrj02 opened this issue 9 months ago • 1 comments

Is there an existing issue for this?

  • [x] 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

mrj02 avatar Mar 29 '25 15:03 mrj02

Apologies for the delayed response. We won't prioritize Blazor SSR + Interactive until the Blazor team resolves this issue. In the meantime, I suggest using Blazor WebAssembly with pre-rendering for fast websites and apps, like https://bitplatform.dev itself!

ysmoradi avatar Apr 23 '25 13:04 ysmoradi

I'm closing this issue since there hasn't been any activity here for a long time. Feel free to open it if needed.

msynk avatar Aug 03 '25 13:08 msynk