Blazor Server - ProtectedLocalStorage Handling When Changing Docker Container?

I am hosting a Blazor Server application using a Docker container. My project has a page that loads the following code from local storage, utilizing OnAfterRednerAsync:

@using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage
@inject ProtectedLocalStorage ProtectedLocalStore

@code {
    public List<long>? upvoted = new List<long>();
    public List<long>? downvoted = new List<long>();
    private bool isConnected;

    protected override async Task OnAfterRenderAsync(bool firstRender)
    {
        if (firstRender)
        {
            isConnected = true;
            await LoadStateAsync();
            StateHasChanged();
        }
    }

    private async Task LoadStateAsync()
    {
        var resultUpvoted = await ProtectedLocalStore.GetAsync<List<long>>("upvoted");
        upvoted = resultUpvoted.Success ? resultUpvoted.Value : new List<long>();
        var resultDownvoted = await ProtectedLocalStore.GetAsync<List<long>>("downvoted");
        upvoted = resultDownvoted.Success ? resultDownvoted.Value : new List<long>();
    }
}

Whenever I update my project, I update and run the new Docker container on my host machine. Any clients that have a value stored in ProtectedLocalStorage are not able to reload or view the page utilizing ProtectedLocalStorage again until they enter their browser tools and manually clear the local storage data.

UPDATE: The issue lies in the await ProtectedLocalStore.GetAsync<List<long>>("upvoted"); trying to cast encrypted values to <List>. When a new Docker container is created, it can no longer decrypt the existing local storage. Is it possible to have new containers be able to decrypt the existing local storage? Perhaps I could mount something that handles this process to my container so that it stays the same for each new container?



Comments

Popular posts from this blog

Today Walkin 14th-Sept

Spring Elasticsearch Operations

Hibernate Search - Elasticsearch with JSON manipulation