我目前正在使用.net core 6和项目设置为defult个人用户accoutant,thta后,我是relazize我想改变returnURL从登录,我不希望它返回自我行动的网址,我想改变到特定的网址,但我被告知需要找到/Login. cshtml. cs和改变它从OnPostAsync方法,但所有我能找到的是区域/身份/页面/_viewstart.cshtml,里面是引导我到_layout. cs html,然后我去布局页面,我发现_loginParitial页面,页面里面的代码是
@using Microsoft.AspNetCore.Identity
@inject SignInManager<IdentityUser> SignInManager
@inject UserManager<IdentityUser> UserManager
<ul class="navbar-nav">
@if (SignInManager.IsSignedIn(User))
{
<li class="nav-item">
<a class="nav-link text-dark" asp-area="Identity" asp-page="/Account/Manage/Index" title="Manage">Hello @User.Identity?.Name!</a>
</li>
<li class="nav-item">
<form class="form-inline" asp-area="Identity" asp-page="/Account/Logout" asp-route-returnUrl="@Url.Action("Index", "Home", new { area = "" })">
<button type="submit" class="nav-link btn btn-link text-dark">Logout</button>
</form>
</li>
}
else
{
<li class="nav-item">
<a class="nav-link text-dark" asp-area="Identity" asp-page="/Account/Register">Register</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="Identity" asp-page="/Account/Login">Login</a>
</li>
}
</ul>
谁能告诉我如何修改返回的URL?我需要自己创建吗?
1条答案
按热度按时间q7solyqu1#
您需要将scaffold Identity添加到您的项目中,以查找具有相应
Login.cshtml.cs
后端代码的Areas/Identity/Pages/Account/Login.cshtml
页面。查看官方文档,了解如何构建身份:将身份搭建到Razor项目中并获得授权