Disabling parts of ASP.NET Core Identity

This article shows how to disable parts of ASP.NET Core Identity in a Web Application. In the ASP.NET Core Identity, the Identiy UI is deployed as part of the NuGet package. So per default everything is enabled and you have to opt-out, unlike the older versions which was opt-in. If you are not careful, this could cause security holes in your application. It is important that you disable the parts of Identity which you do not use!

To demonstrate this, the register process will be disabled. Sometimes, the users are imported or defined using an existing application/process, and the application should not be allowed to register users, so it needs to be deactivated. Per default, it is added and needs to be removed. The default Register Razor Page can be reached at the following URL:

“App base URL”/Account/Register

To turn this off, you need to scaffolding the Razor Page into the application:

Then open the razor view and replace the register code:

    ViewData["Title"] = "Register";

<h2>Disabled go away!</h2>

And also replace the register logic from this view.

using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc.RazorPages;

namespace AspNetCoreIdentityTest.Areas.Identity.Pages.Account
    public class RegisterModel : PageModel
        public void OnGet()

Now if someone tries to open the register code directly, the scaffolded page with no register logic will be requested, and not the default Razor Page from the NuGet package.

You could also just redirect, if some calls the OnGet method. But you must implement an override!

I don’t think the UI razor views should be included as part of the default Identity NuGet package. We should have an opt-in flow.






  1. […] Disabling parts of ASP.NET Core Identity – Damien Bowden […]

  2. […] Disabling parts of ASP.NET Core Identity (Damien Bowden) […]

  3. Reblogged this on Neel Bhatt and commented:
    Nice one. Re blogging on my site.

  4. […] Disabling Parts of ASP.NET Core Identity […]

  5. I agree, this is completely bonkers, they should re-open this issue:


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: