Reputation: 1900
I am have a WinForms App running .Net 4.5.2.
When logging in, I create a ClaimsPrincipal with a bunch of claims. I save to the Thread.CurrentPrincipal. In the same logging-in process, the ClaimsPrincipal works fine.
After the application initializes, when the user clicks on a control, I try to retrieve the ClaimsPrincipal from ClaimsPrincipal.Current. When I do, it is a GenericPrincipal and it loses all its claims.
What am I doing wrong?
Upvotes: 0
Views: 599
Reputation: 1900
It seems this is an issue with WinForms and .Net 4.5.2. Microsoft did say they were going to stop supporting WinForms.
What I found in this case is that if you call ClaimsPrincipal.Current before you set it through Thread.CurrentPrincipal... you run into trouble.
Either the static object gets set to a default GenericPrincipal or the Thread.CurrentPrincipal gets reset.
Whatever the reason the instability is there.
Upvotes: 1