Get list of roles in asp net core
HTML-код
- Опубликовано: 9 окт 2024
- How to retrieve and display all roles in asp.net core using the Identity API.
Text version of the video
csharp-video-t...
Healthy diet is very important for both body and mind. We want to inspire you to cook and eat healthy. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking.
/ @aarvikitchen5572
Slides
csharp-video-t...
ASP.NET Core Text Articles & Slides
csharp-video-t...
ASP.NET Core Tutorial
• ASP.NET core tutorial ...
Angular, JavaScript, jQuery, Dot Net & SQL Playlists
www.youtube.co...
We want to display
1. Role ID
2. Role Name and
3. A pair of buttons to Edit and Delete a role
Roles property of RoleManager class
Roles property of RoleManager class returns the list of all IdentityRole objects
Pass the list of IdentityRole objects to the view for display
[HttpGet]
public IActionResult ListRoles()
{
var roles = roleManager.Roles;
return View(roles);
}
List Roles View
ID property of the IdentityRole object returns the role ID
Name property of the IdentityRole object returns the role Name
We are using Bootstrap 4 cards for styling the list of roles
Thank you so much for this playlist! You´re clearing many doubts i had! Thank you Sir!
Awesome man! Clearly represented and learning a few tricks along the way. Since the Microsoft documentation on how to properly make use of the inbuilt Identity Models is kinda lacking im happy i found your nice tutorial. Thank you!
Microsoft's documentation is not only "kinda lacking" but also kinda frustratingly hard to learn from. (Maybe they designed it for experienced developers)
You are the BEST!
First thanks for the hundreds of hours you spend to teach us!
How could we prevent that not everyone should have the possibility to create a role?
by applying authorize attribute on the Manage Roles Controller. e.g [Authorize(Roles = "Super Admin")]. it will only allow super admin to create, edit or delete the role. Also, you can use policy for this purpose
@@imikhan83 Thanks
Great Question David. As @imi said we use Authorize attribute. We will discuss how we could use role based authorization to control who can and cannot create roles in detail in our upcoming videos. Please stay tuned.
@@Csharp-video-tutorialsBlogspot Thanks, and thanks again for your beautiful lectures!
Thanks. You're explanation is so clear and helpful :)
Amazing as always !!! Thank you Venkat.
This channel is very helpful
Great. Thank you as always.
Sir, kindly do explain one more point, if permissions should be granted to roles or they can be granted to an individual user also. Thank You To Legend Sir Venkat.
it depends upon the scenarios.
Sure Ali - We will discuss in our upcoming videos.
@@Csharp-video-tutorialsBlogspot Hope so sir.
Thank you,
Pretty nice and easey as allways, Thak's man.
I solved the problem by replacing @model IEnumerable
WITH
@model IEnumerable
you are a time saver man thanks
Or you can add
@using Microsoft.AspNetCore.Identity
into _Viewimports.cshtml so you don't need to add this long lines everytime you need this library
Same with others, saves time and makes files less flooded with garbage
Thanks Bro ❤️
How can "Role name 'Admin' is already taken" validation error be displayed in another language?
Yeah I was also wandering about the localization possibilities in ASP NET. But I think its easy to google something on this.
so perfect. Thanks a lot
Good explanation sir..
why for the buttons we are using instead of normal ? . When i use , the button does not work
I have a problem adding IdentityRole to IEnumerable type or namespace is could not found???
Use this:- IEnumerable
@@meetshrivastava197 thank you brother
@@meetshrivastava197 Had a same problem. This worked, thank you!
Plz make videos on generic repository service using dapper with dependency injection
thank you 😁
Sir let me know how to search, sort and filter all
thanks
i can not import IdentityRole. It say the type or namespace is missing.
how to fix that?
figured it out....I had to add to the view @using Microsoft.AspNetCore.Identity;
Hello Nick. Quick tip here. On the red squiggly line if you press CTRL + Period (.) keys simultaneously visual studio will let you know the missing namespace and you can then simply press the ENTER key which will automatically include the required using. Hope this tip helps.
Hey I went through the same error. For this open Start.cs..... make sure services.AddIdentity..........You have to add IdentityRole.
You can just put that view model in the model instead of viewmodel
i get error saying i have missing directive please help
Hen Hao!!!
Sir where can I get the source code?
You can start step by step from the beggining of this series course and you will have your code. Venkat has a GREAT explaination , you will have no prob.
@@MikeS-yg7bv it's not mandatory to start from the beginning if you already have very solid understanding of asp.net core...
Hello Ivandro - You can find the source code on our blog at the following link. Hope this helps.
csharp-video-tutorials.blogspot.com/2019/01/aspnet-core-tutorial-for-beginners.html
IL King int