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

Blazor - Read a cookie value in pre-rendering and OnInitializeAsync

$
0
0

I have a Blazor Server .NET 8 web application that uses/calls a DLL for various tasks including retrieving and reading the value of a cookie. Basically, the DLL used HttpContext, which is not always available in Blazor.

Thank you,Max

I therefore tried to use JSRuntime, but I have to retrieve the cookie in the page initialization, so this solution isn't possible.

I tried using HttpContext only when it's available (pre-rendered) and saving a static variable from a class in my DLL, hoping that it would persist too, but that didn't work.

I also tried using the "Scoped" feature, without success.

I can't see any other solution at the moment... help!

The crazy thing is that I'm able to access my cookie during pre-rendering, my DLL is doing its job well. Then on the second page execution, the HttpContext disappears and I don't know how to retrieve the cookie.


Viewing all articles
Browse latest Browse all 4839

Trending Articles



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