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

Комментарии • 48

  • @code8180
    @code8180 4 года назад +2

    Thank you so much for this playlist! You´re clearing many doubts i had! Thank you Sir!

  • @janeymers7154
    @janeymers7154 4 года назад +5

    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!

    • @adnanmohamed6517
      @adnanmohamed6517 3 года назад +3

      Microsoft's documentation is not only "kinda lacking" but also kinda frustratingly hard to learn from. (Maybe they designed it for experienced developers)

  • @Olegcowboyoleg
    @Olegcowboyoleg Год назад

    You are the BEST!

  • @davidyungrise4442
    @davidyungrise4442 5 лет назад +1

    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?

    • @imikhan83
      @imikhan83 5 лет назад +1

      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

    • @davidyungrise4442
      @davidyungrise4442 5 лет назад

      @@imikhan83 Thanks

    • @Csharp-video-tutorialsBlogspot
      @Csharp-video-tutorialsBlogspot  5 лет назад +3

      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.

    • @davidyungrise4442
      @davidyungrise4442 5 лет назад

      @@Csharp-video-tutorialsBlogspot Thanks, and thanks again for your beautiful lectures!

  • @adnanmohamed6517
    @adnanmohamed6517 3 года назад

    Thanks. You're explanation is so clear and helpful :)

  • @MikeS-yg7bv
    @MikeS-yg7bv 5 лет назад +1

    Amazing as always !!! Thank you Venkat.

  • @dotalord
    @dotalord 5 лет назад

    This channel is very helpful

  • @naodagere8210
    @naodagere8210 4 года назад

    Great. Thank you as always.

  • @alihameed2457
    @alihameed2457 5 лет назад +1

    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.

  • @foxlatinomx
    @foxlatinomx 5 лет назад

    Pretty nice and easey as allways, Thak's man.

  • @johnroygeralde7325
    @johnroygeralde7325 3 года назад +1

    I solved the problem by replacing @model IEnumerable
    WITH
    @model IEnumerable

    • @farzaibsheikh9764
      @farzaibsheikh9764 2 года назад

      you are a time saver man thanks

    • @damianpiotrowski6337
      @damianpiotrowski6337 2 года назад +3

      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

    • @AbdulRafay-wy3ve
      @AbdulRafay-wy3ve 2 года назад

      Thanks Bro ❤️

  • @senolkurt7864
    @senolkurt7864 5 лет назад +3

    How can "Role name 'Admin' is already taken" validation error be displayed in another language?

    • @get_ready
      @get_ready 4 года назад

      Yeah I was also wandering about the localization possibilities in ASP NET. But I think its easy to google something on this.

  • @menakasattmann5335
    @menakasattmann5335 5 лет назад

    so perfect. Thanks a lot

  • @sakthivel-lc9ni
    @sakthivel-lc9ni 5 лет назад

    Good explanation sir..

  • @lifetraveler8008
    @lifetraveler8008 4 года назад

    why for the buttons we are using instead of normal ? . When i use , the button does not work

  • @osmansiddik2597
    @osmansiddik2597 4 года назад +1

    I have a problem adding IdentityRole to IEnumerable type or namespace is could not found???

  • @dotalord
    @dotalord 5 лет назад

    Plz make videos on generic repository service using dapper with dependency injection

  • @davidespada01
    @davidespada01 5 лет назад

    thank you 😁

  • @meetshrivastava197
    @meetshrivastava197 4 года назад

    Sir let me know how to search, sort and filter all

  • @MmMm-tg5mq
    @MmMm-tg5mq 5 лет назад

    thanks

  • @Time21
    @Time21 4 года назад

    i can not import IdentityRole. It say the type or namespace is missing.
    how to fix that?

    • @Time21
      @Time21 4 года назад +1

      figured it out....I had to add to the view @using Microsoft.AspNetCore.Identity;

    • @Csharp-video-tutorialsBlogspot
      @Csharp-video-tutorialsBlogspot  4 года назад +1

      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.

    • @santoshdevkota1959
      @santoshdevkota1959 4 года назад

      Hey I went through the same error. For this open Start.cs..... make sure services.AddIdentity..........You have to add IdentityRole.

  • @justshukri9407
    @justshukri9407 2 года назад

    You can just put that view model in the model instead of viewmodel

  • @phillipmiller4642
    @phillipmiller4642 4 года назад

    i get error saying i have missing directive please help

  • @ball14886
    @ball14886 5 лет назад

    Hen Hao!!!

  • @ivandrofly
    @ivandrofly 5 лет назад

    Sir where can I get the source code?

    • @MikeS-yg7bv
      @MikeS-yg7bv 5 лет назад

      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.

    • @ivandrofly
      @ivandrofly 5 лет назад +1

      @@MikeS-yg7bv it's not mandatory to start from the beginning if you already have very solid understanding of asp.net core...

    • @Csharp-video-tutorialsBlogspot
      @Csharp-video-tutorialsBlogspot  5 лет назад +1

      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

  • @ethanbarca
    @ethanbarca 4 года назад

    IL King int