Getting Started With ASP.NET Core 2.0 Identity And Role Management

In this article, we will see in detail how to use ASP.NET Core Identity in MVC Application for creating user roles and displaying the menu depending on user roles.

C# (2.1 MB)
5 Star
1,363 times
Add to favorites
E-mail Twitter Digg Facebook

Solution explorer

@model ExternalLoginsViewModel
    ViewData["Title"] = "Manage your external logins";

@Html.Partial("_StatusMessage", Model.StatusMessage)
@if (Model.CurrentLogins?.Count > 0)
    <h4>Registered Logins</h4>
    <table class="table">
            @foreach (var login in Model.CurrentLogins)
                        @if (Model.ShowRemoveButton)
                            <form asp-action="RemoveLogin" method="post">
                                    <input asp-for="@login.LoginProvider" name="LoginProvider" type="hidden" />
                                    <input asp-for="@login.ProviderKey" name="ProviderKey" type="hidden" />
                                    <button type="submit" class="btn btn-default" title="Remove this @login.LoginProvider login from your account">Remove</button>
                            @: &nbsp;
@if (Model.OtherLogins?.Count > 0)
    <h4>Add another service to log in.</h4>
    <hr />
    <form asp-action="LinkLogin" method="post" class="form-horizontal">
        <div id="socialLoginList">
                @foreach (var provider in Model.OtherLogins)
                    <button type="submit" class="btn btn-default" name="provider" value="@provider.Name" title="Log in using your @provider.DisplayName account">@provider.DisplayName</button>