0
rickfrankel created
Prerequisites
Please answer the following questions before submitting an issue. YOU MAY DELETE THE PREREQUISITES SECTION.
- What is your product version?
- 10.3
- What is your product type (Angular or MVC)?
- Angular
- What is product framework type (.net framework or .net core)?
- .Net Core
AccountAppService.cs:166
This GetUserByIdAsync will throw an exception if the userID is not found. The code after it checks for user!=null and user ==null which would never happen and thus the user gets an UnFriendlyException message.
I change my code to
var user = await UserManager.Users.FirstOrDefaultAsync(u => u.Id == input.UserId);
to get ensure we could get a null user.
PS: I'm not sure how my user actually got this error, but we had a case where someone was trying to activate with userid = 0 which threw this exception. We're still investigating that.
1 Answer(s)
-
0
Hi @rickfrankel,
Thank you for sharing this, I have changed the related line to;
var user = await UserManager.FindByIdAsync(input.UserId.ToString());