IOT Virtual Conference - Register now to book your ticket and get updates
x
WIN Surface Laptop 4, i7 Processor, 16GB RAM, 512GB SSD
x
CONGRATULATIONS! C# Corner Q1, 2021 MVPs Announced
Why Join
Become a member
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
C# Corner Home
Technologies
Monthly Leaders
ASK A QUESTION
Forumguidelines
Rameez Javed
1.7k
319
21.6k
Get ID of recently created User Role using Identity .net core 2.0
Sep 21 2020 11:57 PM
Hi, I have created new role using identity and want to get Id for this recently created Role on result.succeded.
I'm using the approach like below
public
async Task<IActionResult> CreateRole(CreateRoleViewModel model)
{
if
(ModelState.IsValid)
{
IdentityRole identityRole =
new
IdentityRole
{
Name = model.RoleName
};
IdentityResult result = await roleManager.CreateAsync(identityRole);
if
(result.Succeeded)
{
// Here I want to get the RoleId created newly.
return
RedirectToAction(
"Index"
,
"Admin"
);
}
foreach
(IdentityError error
in
result.Errors)
{
ModelState.AddModelError(
""
, error.Description);
}
}
return
View();
}
Thanks in advance :)
Reply
Answers (
1
)
Linq Query Return zero rows how to make left join with linq
uploaded image not display in mvc