© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•4y ago•
2 replies
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));
            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
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

✅ jwt token
C#CC# / help
14mo ago
❔ JWT TOKEN
C#CC# / help
4y ago
✅ Azure app service Web API project not running
C#CC# / help
2y ago
❔ JWT Authentication: Name goes to claims not identity.Name
C#CC# / help
3y ago