razorasp.net-coreasp.net-core-mvcasp.net-identity

ASP.NET Core - Scaffold Identity like MVC


I have created a Web Application MVC project with Individuals User Accounts authentication.

Afterwards I created a custom UserIdentity. I am trying to change the default "Register" view of Identity adding my new fields, however I only managed to scaffold new pages as Razor Pages.

My question is: Is it possible to scaffold these new views in some structure like MVC? I would not like to mix MVC with Razor Pages at all.

If this is not possible, is there any way to creating a controller that overrides the default behavior (Identity/Account/Register for example)?


Solution

  • For anyone that wants to "scaffold" identity on MVC, I recommend the following approach:

    Go to the official identity ASP.net Github Repository (https://github.com/dotnet/aspnetcore/tree/main/src/Identity/samples/IdentitySample.Mvc) and copy the necessary files to your project.

    Important Note: Don't forget to change the namespace on the added files since they belong to a different project.