在Controllers中新建AccountController,并在构造方法(函数)中注入SignInManager,UserManager

UserManager   用户管理(注册,查找,修改,删除用户等)

SignInManager 用户登录管理(登录,注销等)

private readonly SignInManager<IdentityUser> _signInManager;
private readonly UserManager<IdentityUser> _userManager; public AccountController(SignInManager<IdentityUser> signInManager, UserManager<IdentityUser> userManager)
{
_signInManager = signInManager;
_userManager = userManager;
}

创建Index方法显示所有用户

public async Task<IActionResult> Index()
{
var user = await _userManager.Users.ToListAsync();
return View(user);
}

创建Index.cshtml视图

@model IEnumerable<Microsoft.AspNetCore.Identity.IdentityUser>
@{
ViewData["Title"] = "Index";
} <h1>Index</h1>
<a asp-action="Register">注册</a>
<table class="table table-bordered">
<tr>
<th>@Html.DisplayNameFor(u => u.Id)</th>
<th>@Html.DisplayNameFor(u => u.UserName)</th>
<th>@Html.DisplayNameFor(u => u.Email)</th>
<th>@Html.DisplayNameFor(u => u.PhoneNumber)</th>
<th>操作</th>
</tr>
@foreach (var item in Model)
{
<tr>
<td>@item.Id</td>
<td>@item.UserName</td>
<td>@item.Email</td>
<td>@item.PhoneNumber</td>
<td><a asp-action="EditUser" asp-route-id="@item.Id" type="button" class="btn btn-success btn-xs">修改</a>
<a asp-action="Delete" asp-route-id="@item.Id" type="button" class="btn btn-danger btn-xs" size="">删除</a> </td>
</tr>
}
</table>

显示结果如下(默认没有任何用户,但不方便展示效果故手工新增数据)

最新文章

  1. 解决程序出现“terminate called after throwing an instance of &#39;std::bad_alloc&#39; what(): std::bad_alloc Aborted (core dumped)”的问题
  2. WebView一般用法总结
  3. ios设备相关
  4. Java Hotspot G1 GC的一些关键技术
  5. svn 文件夹 无法提交
  6. Spring 注入数据源
  7. AndroidService 深度分析(2)
  8. 上传代码到GitHub时,遇到错误:fatal,The Requested URL return error 403
  9. Java多线程缓存器简单实现
  10. PHP--最常用--必背函数总结!php学习者收藏必备!
  11. Python面向对象——重写与Super
  12. 《深入理解Java虚拟机》-----第6章 类文件结构——Java高级开发必须懂的
  13. 【python-appium】appium 关键字
  14. Learn to securely share files on the blockchain with IPFS!
  15. python 正则括号的使用及踩坑
  16. 【BZOJ4827】【HNOI2017】礼物
  17. Git:多人推送/抓取分支事项
  18. SQL语句报错,无法绑定由多个部分组成的标识符解决
  19. Python获取路径下所有文件名
  20. FPGA远程更新之限制条件

热门文章

  1. &#127942;(不要错过!)【CI/CD技术专题】「Jenkins实战系列」(3)Jenkinsfile+DockerFile实现自动部署
  2. 在阿里云上单机部署k8s
  3. 表单验证插件jquery-validation以及案例
  4. Jarvis OJ部分逆向
  5. 攻防世界pwn高手区——pwn1
  6. Git点赞82K!字节跳动保姆级Android学习指南,干货满满
  7. java常见面试题目
  8. Create Shortcut to Get Jar File Meta Information
  9. JVM G1GC的算法与实现
  10. 不懂Ribbon原理的可以进来看看哦,分析RibbonClientConfiguration完成了哪些核心初始操作