(环境:Visual Studio 2019 v16.4.3)
我使用以下选项创建一个新的“ ASP.NET Core Web应用程序”
在Visual Studio中运行该应用程序并在浏览器中单击“登录”将转到下一页。https:// localhost:44343 / Identity / Account / Login?returnUrl =%2Fauthentication%2Flogin
我在Angular或ASP.NET Core代码中找不到该页面。如何自定义登录页面?
该模板使用ASP.NET Core Identity进行身份验证和存储,并与IdentityServer结合使用以实现Open ID Connect。因此您需要在ASP.NET Core项目中使用Scaffold Identity来修改UI,例如login,register user等等。
如果使用Visual Studio:
project > Add > New Scaffolded Item
在“添加脚手架”对话框的左窗格中,选择Identity > Add
。
选择要覆盖的文件,例如,登录相关:Account \ Login。
ApplicationDbContext
默认情况下。Add
按钮。如果使用.net core CLI
使用模板创建项目:dotnet new angular --auth Individual
并构建项目。
如果您以前尚未安装ASP.NET Core脚手架,请在vs代码中将其安装在终端中:
dotnet tool install -g dotnet-aspnet-codegenerator
向项目添加所需的NuGet包引用:
dotnet add package Microsoft.VisualStudio.Web.CodeGeneration.Design
dotnet add package Microsoft.EntityFrameworkCore.SqlServer
您可以列出可以安装在脚手架上的文件 dotnet aspnet-codegenerator identity --listFiles
使用所需的选项运行Identity脚手架,用于--files
脚手架特定文件,为数据库上下文使用正确的标准名称:
dotnet aspnet-codegenerator identity -dc ProjectName.Data.ApplicationDbContext --files "Account.Register;Account.Login"
如果您在未指定--files
标志或--useDefaultUI
标志的情况下运行身份支架,则将在项目中创建所有可用的身份UI页面。
现在,如果要修改登录UI,则可以在your project --> Areas-->Identity -->Pages-->Account -->Login.cshtml
页面中修改相关页面。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句