(Environment: Visual Studio 2019 v16.4.3)
I create a new “ASP.NET Core Web Application” with the following options
- ASP.Net Core 3.1
- Angular
- Authentication of Individual User Account (with “Store user accounts in-app”, the only option)
Running the application in Visual Studio and clicking Login in the browser will go to the following page.
https://localhost:44343/Identity/Account/Login?returnUrl=%2Fauthentication%2Flogin
I cannot find the page in the Angular or ASP.NET Core code. How to customize the login page?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
The template uses ASP.NET Core Identity for authenticating and storing users is combined with IdentityServer for implementing Open ID Connect. So that you need to Scaffold Identity in ASP.NET Core projects to modify the UI like login , register user …
If using Visual Studio :
- From Solution Explorer, right-click on the
project > Add > New Scaffolded Item -
From the left pane of the Add Scaffold dialog, select
Identity > Add. - Choose Files to override ,For example , login related : AccountLogin .
- Select your data context class :
ApplicationDbContextby default . - Click
Addbutton.
If using .net core CLI
-
Create project using template :
dotnet new angular --auth Individualand build the project . -
If you have not previously installed the ASP.NET Core scaffolder, install it in terminal in vs code :
dotnet tool install -g dotnet-aspnet-codegenerator -
Add required NuGet package references to the project :
dotnet add package Microsoft.VisualStudio.Web.CodeGeneration.Designdotnet add package Microsoft.EntityFrameworkCore.SqlServer -
You can list the files that can be scaffolded with
dotnet aspnet-codegenerator identity --listFiles -
Run the Identity scaffolder with the options you want , use
--filesto scaffold specific files ,use the correct fully qualified name for your DB context:dotnet aspnet-codegenerator identity -dc ProjectName.Data.ApplicationDbContext --files "Account.Register;Account.Login"If you run the Identity scaffolder without specifying the
--filesflag or the--useDefaultUIflag, all the available Identity UI pages will be created in your project.
Now if you want to modify the login UI , you can modify relevant page in your project --> Areas-->Identity -->Pages-->Account -->Login.cshtml page .
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0