Reputation: 1623
I have setup a Blazor WebAssembly ASP.NET Core hosted
application and integrated the authentication system as well as the custom AuthenticationProvider
to the client. In the server side project I am calling in the controller this:
[HttpGet]
public async Task<ActionResult> GetObjects()
{
var id = User.FindFirstValue(ClaimTypes.NameIdentifier); // <-- returns always null
}
and the id
variable is always returning null.
The user is from the aspnetcoreuser table (aspnetcore identity)
In the table data I can see, as I am using SQLite, that the id is not null and ther users got added succesfully to the aspnetuser
table.
Some SDK-Versions:
.NET Core SDKs installed: 3.1.301 .NET Core runtimes installed: Microsoft.AspNetCore.All 2.1.19 Microsoft.AspNetCore.App 2.1.19Microsoft.AspNetCore.App 3.1.5 Microsoft.NETCore.App 2.1.19 Microsoft.NETCore.App 3.1.5 Microsoft.WindowsDesktop.App 3.1.5
Also I have seen some solutions that the "windowsAuthentication": true, "anonymousAuthentication": false,
from the launchSettings.json
can cause that but with changes it does not solved it for me.
Anyone here who can help me out?
Upvotes: 2
Views: 3932