I'm trying to access the User of the HttpContext via httpContextAccessor.HttpContext.User
.
Unfortunately, it is always null
.
In my launchSettings.json
I have windowsAuthentication set to true and anonymousAuthentication to false.
"iisSettings": {
"windowsAuthentication": true,
"anonymousAuthentication": false,
"iis": {
"applicationUrl": "http://localhost/Sw.Intranet.Webclient",
"sslPort": 0
},
"iisExpress": {
"applicationUrl": "http://localhost:55425",
"sslPort": 44340
}
},
[...]
}
In my Startup, I have the middleware configured in this order:
- app.UseRouting()
- app.UseAuthorization()
- app.UseEndpoints(...)
I have configured the HttpContextAccessor: services.TryAddSingleton<IHttpContextAccessor, HttpContextAccessor>();
Is there anything else I could check / I have missed why the User is always null?
Thanks in advance