This guide explains how to make your application "invite-only" by removing the ability for users to register themselves. Only administrators will be able to create new user accounts.
In appsettings.json, set:
"Registration": {
"AllowSelfRegistration": false, // Set to false
...
}
In Pages/Shared/_LoginPartial.cshtml, delete the Register link:
<!-- DELETE this line: -->
<li class="nav-item">
<a class="nav-link text-dark" asp-page="/Account/Register">Register</a>
</li>
Delete these files from Pages/Account/:
Register.cshtml and .cshtml.csRegisterConfirmation.cshtml and .cshtml.cs (if exists)RegistrationPending.cshtml and .cshtml.csIn Pages/Account/Login.cshtml, remove the "Register" link if present:
<!-- DELETE: "New user? Register here" link -->
<p>
New user? <a asp-page="./Register">Create an account</a>
</p>
In appsettings.json, you can now remove registration-related settings:
// DELETE this section if fully removing registration:
"Registration": {
"AllowSelfRegistration": false,
"RequireApproval": true // No longer needed
}
Search your codebase for references to registration and remove:
Program.csAllowSelfRegistration configuration readsThe Admin section now becomes the only way to create users. Ensure the
Pages/Admin/Users/Create.cshtml page works as expected.
If you're removing self-registration, you should also remove the approval workflow since it's no longer needed.
After removal, verify:
/Account/Register returns 404