本文介绍了AspNet Core脚手架应用程序中的“登录"和“注册"页面在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在VS 2017中,我创建了一个新的ASP.NET Core Web应用程序.在向导的第二页上,选择"Web应用程序",并为身份验证"选择个人用户帐户".

In VS 2017, I created a new ASP.NET Core Web Application. On the second page of the wizard, I chose Web Application, and for Authentication I chose "Individual User Accounts".

现在,我正在尝试查找与/Account/Register和/Account/Login关联的页面.

_Layout.cshtml引入_LoginPartial.cshtml,就像在经典MVC中一样:

_Layout.cshtml brings in _LoginPartial.cshtml, much as it did in classic MVC:

<div class="navbar-collapse collapse">
    <ul class="nav navbar-nav">
        <li><a asp-page="/Index">Home</a></li>
        <li><a asp-page="/About">About</a></li>
        <li><a asp-page="/Contact">Contact</a></li>
    </ul>
    <partial name="_LoginPartial" />
</div>

如果用户未登录,则_LoginPartial包含<a>标记,该标记指向登录页面和注册页面:

If the user is not signed in then _LoginPartial includes <a> tags that point to the login and register pages:

<ul class="nav navbar-nav navbar-right">
    <li><a asp-area="Identity" asp-page="/Account/Register">Register</a></li>
    <li><a asp-area="Identity" asp-page="/Account/Login">Login</a></li>
</ul>

这一切似乎都是有道理的.但是我希望Areas文件夹结构包含Register和Login文件夹.它不是.我唯一找到的是_ViewStart.cshtml

That all seems to make sense. But I would have expected the Areas folder structure to include the Register and Login folders. It does not. The only thing I find there is _ViewStart.cshtml

我知道脚手架的代码可以工作,当我运行项目时,注册"链接指向"/Identity/Account/Register",而登录"链接指向"/Identity/Account/Login".单击注册"链接会给我一个注册页面,其中包含文本创建新帐户".

I know that the scaffolded code works, When I run the project, the Register link points to "/Identity/Account/Register" and the Login link points to "/Identity/Account/Login". Clicking on the Register link gets me a registration page that includes the text "Create a new account".

但是我在项目中的任何地方都找不到文本创建新帐户".

But I can't find the text "Create a new account" anywhere in the project.

有人可以告诉我我想念什么吗?

Can someone tell me what I'm missing?

推荐答案

在asp.net core 2.1的预览版中宣布将Identity UI移至新的Razor类库. https://blogs.msdn. microsoft.com/webdev/2018/03/02/aspnetcore-2-1-identity-ui/

It was announced during the preview of asp.net core 2.1 that the Identity UI would be moved to a new Razor Class Library.https://blogs.msdn.microsoft.com/webdev/2018/03/02/aspnetcore-2-1-identity-ui/

如果您更喜欢本地视图,仍然可以将身份视图放入您自己的项目中: https://docs.microsoft.com/zh-cn/aspnet/core/security/authentication/scaffold-identity?view=aspnetcore-2.1&tabs=visual-studio

It is still possible to scaffold the Identity Views into your own project if you prefer local views:https://docs.microsoft.com/en-us/aspnet/core/security/authentication/scaffold-identity?view=aspnetcore-2.1&tabs=visual-studio

这篇关于AspNet Core脚手架应用程序中的“登录"和“注册"页面在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-26 02:39