This guide explains how to completely remove the admin dashboard and all administrative functionality from your application.
Delete the entire Pages/Admin/ folder and all its contents:
Pages/Admin/Index.cshtml - DashboardPages/Admin/Users/ - User managementPages/Admin/Roles/ - Role managementPages/Admin/PendingUsers/ - Approval workflowIn 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>
}
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"));
The Access Denied page may reference admin features. Review
Pages/Account/AccessDenied.cshtml and update the messaging.
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"));
Without admin pages, ensure users can manage themselves via
Pages/Account/Manage/:
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';
After removal, verify:
/Admin returns 404