![](/img/trans.png)
[英]Customize Login Page design for Authentication type : Individual User account ASP.NET core 2.1, MVC, c#
[英]How to customize the login page of ASP.NET Core web application with Angular Individual user account authentication?
(环境: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,比如登录、注册用户...
如果使用 Visual Studio :
project > Add > New Scaffolded Item
从 Add Scaffold 对话框的左窗格中,选择Identity > Add
。
选择要覆盖的文件,例如与登录相关的:帐户\\登录。
ApplicationDbContext
。Add
按钮。如果使用 .net 核心 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
使用您想要的选项运行身份脚手架,使用--files
来脚手架特定文件,为您的数据库上下文使用正确的完全限定名称:
dotnet aspnet-codegenerator identity -dc ProjectName.Data.ApplicationDbContext --files "Account.Register;Account.Login"
如果您在未指定--files
标志或--useDefaultUI
标志的情况下运行 Identity 脚手架,则将在您的项目中创建所有可用的 Identity UI 页面。
现在如果你想修改登录UI,你可以在your project --> Areas-->Identity -->Pages-->Account -->Login.cshtml
页面中修改相关页面。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.