Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/29.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在其中生成SignInManager IdentityUser.cshtml文件_C#_Asp.net_Asp.net Mvc_Asp.net Core - Fatal编程技术网

C# 在其中生成SignInManager IdentityUser.cshtml文件

C# 在其中生成SignInManager IdentityUser.cshtml文件,c#,asp.net,asp.net-mvc,asp.net-core,C#,Asp.net,Asp.net Mvc,Asp.net Core,现在我已经在IdentityUser课程上花了将近一周的时间 我是一个新的asp.net内核,或者我没有遇到类似的东西, 在链接上应用课程时: 未找到文件:EnableAuthenticator.cshtml (Microsoft.AspNetCore.Identity)是生成视图文件的人,但这里的问题是您是否可以以任何方式找到此文件请注意,由newProject>asp.netCore MVC创建的应用程序具有身份验证。 C:\webapplicationcare\webapplication

现在我已经在IdentityUser课程上花了将近一周的时间 我是一个新的asp.net内核,或者我没有遇到类似的东西, 在链接上应用课程时: 未找到文件:EnableAuthenticator.cshtml (Microsoft.AspNetCore.Identity)是生成视图文件的人,但这里的问题是您是否可以以任何方式找到此文件请注意,由newProject>asp.netCore MVC创建的应用程序具有身份验证。 C:\webapplicationcare\webapplicationcare\Views\Shared\u LoginPartial.cshtml

    @using Microsoft.AspNetCore.Identity

@inject SignInManager<IdentityUser> SignInManager
@inject UserManager<IdentityUser> UserManager

@if (SignInManager.IsSignedIn(User))
{
    <form asp-area="Identity" asp-page="/Account/Logout" asp-route-returnUrl="@Url.Action("Index", "Home", new { area = "" })" method="post" id="logoutForm" class="navbar-right">
        <ul class="nav navbar-nav navbar-right">
            <li>
                <a asp-area="Identity" asp-page="/Account/Manage/Index" title="Manage">Hello @UserManager.GetUserName(User)!</a>
            </li>
            <li>
                <button type="submit" class="btn btn-link navbar-btn navbar-link">Logout</button>
            </li>
        </ul>
    </form>
}
else
{
    <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>
}
@使用Microsoft.AspNetCore.Identity
@注入SignInManager SignInManager
@注入用户管理器用户管理器
@if(SignInManager.IsSignedIn(用户))
{
  • 你好@UserManager.GetUserName(用户)!
  • 注销
} 其他的 {
  • 登记册
  • 登录
}
请注意,所需页面将显示在上的浏览器中 https://localhost:***/Identity/Account/Manage/EnableAuthenticator 项目文件夹中根本不存在此文件,是否可以查找和编辑它

如果您在控制问题方面遇到困难,我深表歉意,因为我 使用谷歌翻译


当我们创建具有单独身份验证的ASP.NET核心MVC应用程序时,帐户管理视图和/或页面将隐藏

他们在哪里?它们是ASP.NET核心标识包中的编译视图/页面;我们可以在GitHub存储库中看到它们。举个例子,下面是一个例子

要在我们的项目中显示这些页面,我们需要。下面是如何从dotnet命令行界面执行此操作

这假设ASP.NET核心2.1.0(通过
dotnet--info
检查)

我们还可以生成很多其他文件

// view the help
dotnet aspnet-codegenerator identity -h

// list the available files to generate
dotnet aspnet-codegenerator identity --listFiles

它已经被转移到自己的Razor Pages库中。我可以编辑页面并添加代码吗?@Sultan您可以编辑页面,然后编辑页面。我非常感谢您的努力,这对我来说是一个亮点,除了我的能力之外,非常感谢您的解释。非常漂亮的一种可能性,脚手架可以尽可能地提取隐藏的内容,这可以反转过程并隐藏明显的内容,或者过程只是生成预先编写的代码。
// view the help
dotnet aspnet-codegenerator identity -h

// list the available files to generate
dotnet aspnet-codegenerator identity --listFiles