C
C#2y ago
cyan_live

❔ JWT token claims not working anymore after deploying application to Azure web app.

The code that is working inside a controller locally but not working when deployed on azure Attempt 1#
var obj = _httpContextAccessor.HttpContext;
var currentAccountId = _httpContextAccessor.HttpContext
.User.Claims
.FirstOrDefault(c => c.Type == "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name")?.Value;


var account = _accountService.GetAccountById(int.Parse(currentAccountId));
var obj = _httpContextAccessor.HttpContext;
var currentAccountId = _httpContextAccessor.HttpContext
.User.Claims
.FirstOrDefault(c => c.Type == "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name")?.Value;


var account = _accountService.GetAccountById(int.Parse(currentAccountId));
Attempt 2
var currentAccountId = int.Parse(User.FindFirst(ClaimTypes.Name).Value);
var currentAccountId = int.Parse(User.FindFirst(ClaimTypes.Name).Value);
On Azure I get a null System.ArgumentNullException error on the above line of code
1 Reply
Accord
Accord2y ago
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.