Hello!
I am having an issue with Thread.CurrentPrincipal after migrating from .Net Core 2.2 to .Net Core 3.1
I am setting my Thread.CurrentPrincipal in a Custom Authorization Handler like this:
`
var claims = new List {
new Claim("CustomIdClaim", <user_id>),
new Claim(ClaimTypes.Name, <user_name>)
};
Thread.CurrentPrincipal = new ClaimsPrincipal(new ClaimsIdentity(claims));
`
and then I am trying to get Thread.CurrentPrincipal in a static method initialized in Startup class like this:
var principal = (ClaimsPrincipal)Thread.CurrentPrincipal;
.
The problem is that in the static method, Thread.CurrentPrincipal is always null. I must mention that my custom authorization handler is called before the static method on every request.
This worked just fine with .Net Core 2.2.
Thanks in advance!
Hello!
I am having an issue with Thread.CurrentPrincipal after migrating from .Net Core 2.2 to .Net Core 3.1
I am setting my Thread.CurrentPrincipal in a Custom Authorization Handler like this:
`
var claims = new List {
new Claim("CustomIdClaim", <user_id>),
new Claim(ClaimTypes.Name, <user_name>)
};
`
and then I am trying to get Thread.CurrentPrincipal in a static method initialized in Startup class like this:
var principal = (ClaimsPrincipal)Thread.CurrentPrincipal;.
The problem is that in the static method, Thread.CurrentPrincipal is always null. I must mention that my custom authorization handler is called before the static method on every request.
This worked just fine with .Net Core 2.2.
Thanks in advance!