Below I present a more detailed instruction that will help users customize the login and registration form on their ASP.NET MVC website using the Identity library.
give a star ⭐️ on GitHub - https://github.com/iuno-san/ASP.NET-IdentityCustom
⚡️ Steps to customize the login form
1. Open Visual Studio and load your existing project or create a new MVC project.
2. Right-click on the main part of your MVC project (e.g. on the project name in the Solution Explorer pane).
3. Select "Add" and then "New Scaffolded Item".
4. In the dialog box, select the "Identity" section on the left side.
5. Click the "Add" button.
6. Now all available files will appear, which you can download to your project and change from the Identity package. We are looking for "Account/Login" and "Account/Register" files, so select the corresponding options.
7. Next, you will be asked to select the DbContext class file. If you don't have one, you can create one by clicking on the "Add" button and giving it an optimal name, such as "ApplicationDbContext." You can also select an existing DbContext class.
8. After selecting the DbContext class, click the "Add" button. This will create "Areas/Identity/Data" and "Areas/Identity/Pages/Account" folders in your project, and the "Account" folder will contain the login and registration form files and others related to the Identity library.
9. Now you can access the "Login.cshtml" file located in the "Areas/Identity/Pages/Account" folder and change it according to your preferences.
10. To display the login and registration sections on your page, go to the "_Layout.cshtml" file in the "Views/Shared" folder. Add the following code to import the partial content (_LoginPartial): <partial name="_LoginPartial"/>
11. In the "Program.cs" file, add the following line of code to enable Razor Pages support: app.MapRazorPages();
😎 After completing these steps
the login and registration form modifications should be ready to be displayed on your website. Now you can enjoy the modifications and adapt them to your needs.
Have fun working on your project!
Top comments (0)