Logo

Remove Admin Dashboard

This guide explains how to completely remove the admin dashboard and all administrative functionality from your application.

Major Impact
Removing the admin dashboard removes all of these capabilities: You will need to manage users directly in the database.

When to Remove Admin Dashboard

Step 1: Delete Admin Folder

Delete the entire Pages/Admin/ folder and all its contents:

Step 2: Remove Admin Navigation Link

In Pages/Shared/_LoginPartial.cshtml, delete the Admin link:

<!-- DELETE: Admin link (usually shown for admin users) -->
@if (User.IsInRole("Admin"))
{
    <li class="nav-item">
        <a class="nav-link text-dark" asp-page="/Admin/Index">Admin</a>
    </li>
}

Step 3: Remove Admin Role Requirement

If you no longer need the Admin role at all, you can remove it from the database seed in Data/DbInitializer.cs:

// MODIFY: Remove Admin role creation if not needed
// DELETE this line if no admin role needed:
await roleManager.CreateAsync(new IdentityRole("Admin"));

Step 4: Update Access Denied Page

The Access Denied page may reference admin features. Review Pages/Account/AccessDenied.cshtml and update the messaging.

Step 5: Remove Admin Authorization Policies

In Program.cs, remove any admin-specific authorization policies if they're no longer needed:

// DELETE if not needed:
options.AddPolicy("RequireAdminRole", policy => 
    policy.RequireRole("Admin"));

Step 6: Consider User Self-Management

Without admin pages, ensure users can manage themselves via Pages/Account/Manage/:

Database Considerations

The Admin role and related data can remain in the database. To fully remove:

-- Remove all admin role assignments
DELETE FROM AspNetUserRoles 
WHERE RoleId = (SELECT Id FROM AspNetRoles WHERE Name = 'Admin');

-- Remove the Admin role
DELETE FROM AspNetRoles WHERE Name = 'Admin';

Verification

After removal, verify: