I have a Blazor server side application with a custom identityprovider.
Whenever I need to recover the identity I do so from the session storage using javascript.
This all works well.
But now I have added an upload control and I have embedded it with <CascadingAuthenticationState>
to see if the identity was still known until that point, which it is.
Once I try to upload a file it makes a call to a controller using routing and that's where it goes haywire.
Once I enter the constructor of the controller the identity is null.
All attempts to recover it using javascript result in
JavaScript interop calls cannot be issued at this time. This is because the component is being statically rendered
While I am familiar with this error message, I am puzzled why this happens because the render mode of the application is Server and not ServerPrerendered. Is it because I am in a post event? I've also played with several ways passing the httpcontext but that's also null.
Basically what I'm trying to accomplish is that I need my token there to call an API, but I've lost all track of who I am at that point. I can think of ugly solutions like passing it in the URL, but that's not safe at all. Or store it in a singleton with a lock or something like that, but those are all fugly solutions.
Can anyone kick me into right direction? I feel like I'm running into a very large, very dark forest now.