Globals disappear after Browser Refresh

Hi

I'm having trouble with the Global properties. If I set a Property in Page1 and mark it as Global. In Page2 I create a Label and set the Text to the Global Property created/set in Page1. Everything works fine when I navigate between the two Pages the Global Property displays what is set in Page1. But if on Page2 I hit the refresh button on the browser all the Global Property data is gone until it is set again in Page1.

I have replicated this problem using a blank project with just two Page's.

Is this how it is meant to be? If so how do you handle browser refresh then? I can send a video to demonstrate if that helps. I am using version 2.63.3

Yes. Blazor applications are reset on browser refresh. You need to store them in browser client-side storage. Check this thread: Is there any session storage function I can use in Radzen?

Thank you so much for your help. For anyone else that is interested I have followed the instructions and modified the .razor.cs file to add a GetSession and SetSession functions to use the Protected Browser Storage. Here is the code:

using System;
using System.Linq;
using System.Collections.Generic;
using System.Threading.Tasks;
using Radzen;
using Radzen.Blazor;
using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage;
using Microsoft.AspNetCore.Components;

namespace YourPageName.Pages
{
    public partial class YourPageNameComponent
    {

        [Inject]
        public ProtectedSessionStorage ProtectedSessionStore { get; set; }
        public async Task<string> GetSession(string ValueName)
        {
            var RV = await ProtectedSessionStore.GetAsync<string>(ValueName);
            return RV.Value;
        }

        public async Task SetSession(string ValueName, string Value)
        {
            await ProtectedSessionStore.SetAsync(ValueName, Value);
        }
    }
}

You can then Set and Get session info using the Invoke Custom Method.

3 Likes