MVC Blog: Customize the MvcBlogUser Identity
It would be nice to capture the user name of the user during registration, for use throughout our blog application. AspNetUser already has a Username field, so we'll use that.
The scaffolded Identity views are are contained within a .NET Standard Razor Class Library (RCL), so we need to extract the UI items out to .cshtml files to modify for our new field(s). We can run "dotnet aspnet-codegenerator identity --listFiles" to find out our --files options, then run this:
Under Areas\Identity\Pages we now have _ViewImports.cshtml, and \Account and \Account\Manage files:
So now we can extend our IdentityUser class, MvcBlogUser:
Add a migration, update the database:
Update Areas\Identity\Pages\Account\Register.cshtml:
Update InputModel in Register.cshtml.cs:
Update OnPostAsync in Register.cshtml.cs:
Customize the site header (Views/Shared/_LoginPartial.cshtml):
Customize profile management (Pages/Account/Manage/Index.cshtml):
Customize the InputModel (Pages/Account/Manage/Index.cshtml.cs):
Update LoadAsync:
Update OnPostAsync:
Now we see our name field on the Registration Screen and at the top of the page when we log in: