Identityserver4 如何在Blazor中自定义IdentityServer视图?
我有一个BlazorWebAssembly和Asp.NETCore项目,由个人用户帐户托管(身份验证)。 但我有两个问题。首先,我需要自定义注册和登录视图(与identity server 4相关),但找不到视图。在Identityserver4 如何在Blazor中自定义IdentityServer视图?,identityserver4,blazor-server-side,blazor-client-side,blazor-webassembly,Identityserver4,Blazor Server Side,Blazor Client Side,Blazor Webassembly,我有一个BlazorWebAssembly和Asp.NETCore项目,由个人用户帐户托管(身份验证)。 但我有两个问题。首先,我需要自定义注册和登录视图(与identity server 4相关),但找不到视图。在\u LoginPartial.cshtml视图中的服务器项目(blazor服务器)中,我们可以看到许多页面:asp area=“Identity”asp page=“/Account/Manage/Index”和asp area=“Identity”asp page=“/Accou
\u LoginPartial.cshtml
视图中的服务器项目(blazor服务器)中,我们可以看到许多页面:asp area=“Identity”asp page=“/Account/Manage/Index”
和asp area=“Identity”asp page=“/Account/Register”
,asp area=“Identity”asp page=“/Account/Register”
等等。。。但是身份文件夹是空的!在blazor客户端中,我们还有LoginDisplay.razor
页面:
<NotAuthorized>
<a href="authentication/register">Register</a>
<a href="authentication/login">Log in</a>
</NotAuthorized>
Authentication.razor
组件间接调用IdentityServer 4
如何查找identity server 4视图并对其进行更改
第二个问题是,我想在启动文件blazor服务器中使用自定义标识模型
默认代码为:
services.AddDefaultIdentity<ApplicationUser>(options => options.SignIn.RequireConfirmedAccount = true)
.AddEntityFrameworkStores<ApplicationDbContext>();
services.AddDefaultIdentity(选项=>options.SignIn.RequireConfirmedAccount=true)
.AddEntityFrameworkStores();
当我换成:
services.AddIdentity<ApplicationUser,Role>(options => options.SignIn.RequireConfirmedAccount = true)
.AddEntityFrameworkStores<ApplicationDbContext>();
services.AddIdentity(options=>options.SignIn.RequireConfirmedAccount=true)
.AddEntityFrameworkStores();
当我运行project并单击登录或注册按钮(Authentication.razor
)时,调用IdentityServer(例如:https://localhost:5001/Identity/Account/Register?returnUrl=%2Fauthentication%2Flogin
),请告诉我一个错误:
对不起,这个地址什么也没有
我不知道为什么。在服务器项目中,添加新的脚手架项目对话框,选择标识>添加。我只知道如何自定义文本“您已注销”、“检查登录状态”等等 根据,通过设置
RemoteAuthenticatorView
组件的参数,可以将渲染片段更改为所需的任何内容
您可以自定义9种不同的渲染片段:
完成登录
完成注销
登录
登录失败
注销
注销失败
注销成功
注册
UserProfile
//BlazorApp.Client.Pages.Authentication.razor
@页面“/身份验证/{Action}”
@使用Microsoft.AspNetCore.Components.WebAssembly.Authentication
我正在登录!!//在这里
//还有更多!
更改文本“您已注销”、“检查登录状态”和“授权”有什么想法吗?我想这与IdentityServer4有关。我真的需要这个。。。非常感谢。@ArthurB在中观看图像,如果您找不到这些文字,您必须在客户端blazor项目中搜索。(这是我个人的意见。)谢谢@sda2584541,我已经这么做了,但是当应用程序启动时,当重定向到登录时,以及当您注销时,这些文本都会显示出来,我想这些文本会嵌入到某个地方,我想这可以被覆盖,但我找不到位置。@ArthurB我也不知道。但是如果我理解,我会让你知道的。@ArthurB我找到了如何自定义“授权”文本,你必须在客户端项目中的“App.razor”文件和AuthorizeRouteView
之间创建一个新的authorizing
标记,并在这两者之间编写新的自定义文本。例如:您在此处的自定义文本
“根据文档”。。。给这些文档打电话很费劲。
services.AddIdentity<ApplicationUser,Role>(options => options.SignIn.RequireConfirmedAccount = true)
.AddEntityFrameworkStores<ApplicationDbContext>();