Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

How to pass an object from Layout to page in Blazor .Net 8

$
0
0

I have a Blazor .Net 8 WebApp application with perpage rendering. My layout page is in the server app and is just a plain SSR with no interactivity.I have a scoped service where I set properties from the OnInitializedAsync method in the layout. My page is in the client app and has InteractiveAuto with prerendering = false. In the client page the scoped service does not have any properties set.

In .Net 6 or 7 Server app the values can be retrieved from the page and works perfectly. Apparently scoped services do not hold values across render modes. I cannot use Singleton because these values are user specific.

I have tried CascadingValues, but these cannot cross render modes either. I also tried static properties that also didn't work. I cannot use localstorage because localstorage cannot be used in OnInitializedAsync. I don't want to use OnAfterRenderAsync because these values are needed on every page and I would never be able to use OnInitializedAsync on the pages.

Does anyone know a way to pass the data? I can't imagine I am the only one in need of this.


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>