C#C
C#3y ago
Cyan

❔ 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));


Attempt 2

            var currentAccountId = int.Parse(User.FindFirst(ClaimTypes.Name).Value);


On Azure I get a null System.ArgumentNullException error on the above line of code
Was this page helpful?