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));
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
2 Replies
Accord
Accord3y ago
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.
Mohi
Mohi2w ago
Hi there, facing the same problem, everything works fine on dev server but when depoly on Azure on test env, recieve CORS errors on the endpoints of controllers used [Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)] won't work anymore. Is there any updates?

Did you find this page helpful?