0

我使用 ASP.NET Core 3.1 Blazor webassembly 应用程序(由 Visual Studio 2019 创建的默认应用程序)。

我为用户管理连接了 ASP.NET Identity,添加了脚手架的 Identity 项(登录、注册等)

当我单击Register时,应用程序正确重定向到

https://localhost:44349/Identity/Account/Register

但是如果我单击Login,应用程序将重定向到

https://localhost:44349/Account/Login

这是错误的(我希望https://localhost:44349/Identity/Account/Login

LoginDisplay.razor:

<AuthorizeView>
    <Authorized>
        <a href="authentication/profile">Hello, @context.User.Identity.Name!</a>
        <button class="nav-link btn btn-link" @onclick="BeginSignOut">Log out</button>
    </Authorized>
    <NotAuthorized>
        <a href="authentication/register">Register</a>
        <a href="authentication/login">Log in</a>
    </NotAuthorized>
</AuthorizeView>

我错过了什么?

4

1 回答 1

0

通过更换

services.AddIdentity<ApplicationUser, IdentityRole>(options => options.SignIn.RequireConfirmedAccount = true)
.AddEntityFrameworkStores<ApplicationDbContext>()
.AddDefaultTokenProviders();

services.AddDefaultIdentity<ApplicationUser>(options => options.SignIn.RequireConfirmedAccount = true)
.AddEntityFrameworkStores<ApplicationDbContext>()
.AddDefaultTokenProviders();

我解决了这个问题

于 2020-06-22T19:33:56.153 回答