Core Api User Register Help
Hello. I need help. I'm making the user registration adding process with the log, but I get an error when try add.
8 Replies
Your call to
.First()
cannot find the given element
Nothing matches the predicate
And thus, it throws an exception
That's why it's generally better to use .FirstOrDefault()
and handle the case when the return is null
Why null return ?
Because there's no claim of type
UserRolId
Possibly a typo?
UserRoleId is what you meant?I guess.
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
@Alparslan Just a tips, there is something called Identity that can simplify what you are doing https://learn.microsoft.com/en-us/aspnet/core/security/authentication/identity?view=aspnetcore-6.0&tabs=visual-studio.
Introduction to Identity on ASP.NET Core
Use Identity with an ASP.NET Core app. Learn how to set password requirements (RequireDigit, RequiredLength, RequiredUniqueChars, and more).