Blazor WASM - Upgrading from CSLA 6 to CSLA 8 - Setting ApplicationContext User throws Not Supported Exception #4486
-
I have a Blazor WASM app that I am upgrading CSLA 8. I use AddMsalAuthentication to setup login with Azure AD and AddAccountClaimsPrincipalFactory to set a custom ClaimsPrincipalFactory. In my claims principal factory, I am overrideing the CreateUserAsync method and setting the ApplicationContext as such
This code throws an unsuported exception in when I attempt to upgrade to CSLA 8. If I remove the line that sets the user everything works, but I then lose the user when I navigate from one page (component) to the next. I assume this somehow relates to this but I don't really understand that discussion and also that was not a WASM app. What would be the correct way to set the user in a CSLA 8 Blazor WASM app so that I would not lose the identity after the initial login? For clarity as to what I am doing here is the entire method:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 14 replies
-
The reason CSLA no longer allows setting the Here's an example of a custom In that example, the provider is calling a server endpoint to get the user principal object on request. How you authenticate the user and where you create that authenticated fwiw, I talk about this in my VS Live Blazor talks and in my online Blazor class. |
Beta Was this translation helpful? Give feedback.
Another thing that occurs to me, that you could try, is to use a context manager that does not cache the principal. Maybe that would be better?
Specifically here:
csla/Source/Csla.Blazor.WebAssembly/ApplicationContextManager.cs
Line 77 in 85162c1
Rather than maintaining any reference to the current principal, the code could just always return the value from the task (if available).