TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
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
Forums
Monthly Leaders
Forum guidelines
Rameez Javed
NA
395
61.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
)
WinForm Textbox Values to Ms word template
uploaded image not display in mvc