This guide explains how to remove the admin user management pages (create, edit, delete users). After removal, you'll need to manage users directly in the database or via custom tools.
Delete the entire Pages/Admin/Users/ folder, which contains:
Index.cshtml and .cshtml.cs - User listCreate.cshtml and .cshtml.cs - Create userEdit.cshtml and .cshtml.cs - Edit userDelete.cshtml and .cshtml.cs - Delete userDetails.cshtml and .cshtml.cs - User details (if exists)In Pages/Admin/Index.cshtml, remove the Users link and user count:
<!-- DELETE: Users management card -->
<div class="col-md-4">
<div class="card">
<div class="card-body">
<h5 class="card-title">Users</h5>
...
</div>
</div>
</div>
In Pages/Admin/Index.cshtml.cs, remove:
TotalUsers propertyActiveUsers propertyOnGetAsyncIf you have an admin navigation menu, remove the Users link.
If you're removing self-registration but still need to create users, consider keeping only the Create User page:
Pages/Admin/Users/Create.cshtml and .cshtml.csAfter removing user management UI, you can manage users via:
Example SQL for common tasks:
-- Deactivate a user
UPDATE AspNetUsers SET IsActive = 0 WHERE Email = 'user@example.com';
-- Reset password (requires generating hash - not recommended)
-- Better: Add user to admin role and use password reset
-- Add user to Admin role
INSERT INTO AspNetUserRoles (UserId, RoleId)
SELECT u.Id, r.Id
FROM AspNetUsers u, AspNetRoles r
WHERE u.Email = 'user@example.com' AND r.Name = 'Admin';
After removal, verify:
/Admin/Users returns 404