csla icon indicating copy to clipboard operation
csla copied to clipboard

Preserving state in BlazorExample not working

Open uwefms opened this issue 1 year ago • 3 comments

Describe the bug currentCount is not preserved in Counter.razor in samples/BlazorExample

Version and Platform CSLA version: 10.0.0-beta-0011-gc72d4fb04f with .NET 10 OS: Windows 11 Platform: .NET 10

Version and Platform CSLA version: 9.1.0 with .NET 9 OS: Windows 11 Platform: .NET 9

Code that Fails


        if (applicationContext.LocalContext.Contains("counter"))
        {
            var value = applicationContext.LocalContext["counter"];
            currentCount = value == null ? 0 : (int)value;
        }

When reentering the counter page,

applicationContext.LocalContext.Contains("counter")

is not existing any more.

I could provide the complete code, but it is basically the same as in the samples. I only updated some dlls in .NET 9 and changed to CSLA 9.10 and did the same in .NET 10.

uwefms avatar Nov 25 '25 14:11 uwefms

Thank you @uwefms - I have confirmed that the solution fails. Don't know why yet, but I appreciate you finding the issue!

rockfordlhotka avatar Dec 17 '25 01:12 rockfordlhotka

In digging deeper, it appears that something changed between net8.0 and net9.0 in terms of how the Blazor render pipeline works - at least that's my working theory since this used to work and now doesn't.

The solution appears to be to add middleware for aspnetcore to maintain the CSLA session id cookie before Blazor does any rendering. Testing that idea now.

rockfordlhotka avatar Jan 08 '26 19:01 rockfordlhotka

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

github-actions[bot] avatar Jul 08 '26 01:07 github-actions[bot]