tsuyoshi 羽鳥
[SOLVED] Accessing HttpOnly Cookies during Prerendering
To access cookies (including auth tokens) during prerendering, you can:
1. Inject IHttpContextAccessor in a service used only on the server side.
2. Access the cookie via:
var token = httpContextAccessor.HttpContext?.Request.Cookies["YourCookieName"];
But be careful — this only works during prerendering on the server.
3. Make sure the service accessing the cookie is marked with [CascadingParameter]
or injected differently between server/client, because once it switches to WASM, there’s no HttpContext
.27 replies