1-打开之前写的MvcCookieAuthSample项目, 在AccountController新加Register,Login方法

    public class AccountController : Controller
{
public IActionResult Register()
{
return View();
} public IActionResult Login()
{
return View();
}
}

2-新加LoginViewModel,RegisterViewModel

namespace MvcCookieAuthSample.ViewModel
{
public class LoginViewModel
{
public string Email { get; set; }
public string Password { get; set; } }
}

3-在View/Account/Login.cshtml增加如下代码

<h3>Login</h3>
@model MvcCookieAuthSample.ViewModel.LoginViewModel
<div class="row">
<div class="col-md-4">
<form method="post"> <hr /> <div class="form-group">
<label asp-for="Email"></label>
<input asp-for="Email" class="form-control" />
</div> <div class="form-group">
<label asp-for="Password"></label>
<input asp-for="Password" class="form-control" />
</div> <button type="submit" class="btn btn-default">Login</button>
</form>
</div>
</div>

3-在View/Account/Register.cshtml增加如下代码

<h3>Register</h3>
@model MvcCookieAuthSample.ViewModel.RegisterViewModel
<div class="row">
<div class="col-md-4">
<form method="post">
<h4>register a new account</h4>
<hr /> <div class="form-group">
<label asp-for="Email"></label>
<input asp-for="Email" class="form-control" />
</div> <div class="form-group">
<label asp-for="Password"></label>
<input asp-for="Password" class="form-control" />
</div> <div class="form-group">
<label asp-for="ConfirmPassword"></label>
<input asp-for="ConfirmPassword" class="form-control" />
</div> <button type="submit" class="btn btn-default">Register</button>
</form>
</div>
</div>

4-为了能在导航中直接跳转到当前链接中,在shared/_layout.cshtml

43-Identity MVC:UI的更多相关文章

  1. 任务43:Identity MVC:UI

    基于原来做的cookie认证的代码:MvcCookieAuthSample 增加登陆和退出的方法: 增加Login和SignIn这两个Action方法. 在Views下面创建Account文件夹,然后 ...

  2. Identity MVC:UI

    基于原来做的cookie认证的代码:MvcCookieAuthSample 增加登陆和退出的方法: 增加Login和SignIn这两个Action方法. 在Views下面创建Account文件夹,然后 ...

  3. 任务45:Identity MVC:注册逻辑实现

    任务45:Identity MVC:注册逻辑实现 做登陆 在注册成功直接进行登陆,使用SignIn 这里的signIn实际上是HttpContext.Signin的封装 await _signMana ...

  4. 任务46:Identity MVC:登录逻辑实现

    任务46:Identity MVC:登录逻辑实现 实现登陆的方法 退出方法 _layout里面增加如下的代码: Login.cshtml 运行代码测试: 这个地方的单词之前拼错了.这里进行修正 输入账 ...

  5. 任务47:Identity MVC:ReturnUrl实现

    任务47:Identity MVC:ReturnUrl实现 在最上面加一个私有的方法 登陆也加上returnUrl Login的post方法.加入returnUrl的参数 登陆界面也需要加上 asp- ...

  6. 任务48:Identity MVC:Model后端验证

    任务48:Identity MVC:Model后端验证 RegisterViewModel using System; using System.Collections.Generic; using ...

  7. 任务49:Identity MVC:Model前端验证

    任务49:Identity MVC:Model前端验证 前端验证使用的是jquery的validate的组件 _ValidationScriptsPartial.cshtml 在我们的layout里面 ...

  8. 任务50:Identity MVC:DbContextSeed初始化

    任务50:Identity MVC:DbContextSeed初始化 首先添加seed 每次应用程序启动,监测一下,是否是第一次启动.如果是第一次执行,我们需要在数据库内添加一个记录 比如说我们的用户 ...

  9. 任务44:Identity MVC: EF + Identity实现

    使用VSCode开发 Razer的智能感知不好.所以这里切换为VS2017进行开发: 新建一个Data的文件夹来存放我们的DBContext.在Data文件夹下新建: ApplicationDbCon ...

随机推荐

  1. Jerry的ABAP原创技术文章合集

    我之前发过三篇和ABAP相关的文章: 1. Jerry的ABAP, Java和JavaScript乱炖 这篇文章包含我多年来在SAP成都研究院使用ABAP, Java和JavaScript工作过程中的 ...

  2. 设计模式——代理模式(Proxy Pattern)

    代理模式(Proxy),为其他对象提供一种代理以控制对这个对象的访问. UML图: 模型设计: Subject类: package com.cnblog.clarck; /** * Subject 类 ...

  3. vim编辑下几个退出保存的命令

    :w 将数据写入硬盘 :w! 若文件属性为“只读”时,强制写入该文件.不过需要注意,这个是在你的权限可以改变的情况下才能成立 :q 离开vim :q! 修改过文件,又不想保存 :wq 保存后离开 :w ...

  4. bootstrap table 主子表 局部数据刷新(刷新子表)

    1.主表中设置data-detail-view="true",启用主子表模式: <table class="table table-striped" wi ...

  5. Shell脚本学习之expect命令

     转载:http://blog.csdn.net/leexide/article/details/17485451 目录(?)[-] 一概述 二expect的安装 一Tcl 安装 二expect 安装 ...

  6. BZOJ3262:陌上花开(CDQ分治)

    Description 有n朵花,每朵花有三个属性:花形(s).颜色(c).气味(m),用三个整数表示. 现在要对每朵花评级,一朵花的级别是它拥有的美丽能超过的花的数量. 定义一朵花A比另一朵花B要美 ...

  7. 布局方式-inline-block布局

    .像文本一样排block元素 .没有清除浮动等问题 .需要处理间隙     一种方式 <style> .container{ width: 800px; height: 200px; fo ...

  8. CodeForces-822D 【最小素因子应用】

    任意门:https://vjudge.net/problem/CodeForces-822D D. My pretty girl Noora time limit per test 1.5 secon ...

  9. FMDB初步使用小结

    频繁的网络请求会给用户不好的体验,在最近开发的一个项目中有一个获取个人详细信息的界面,由于是子页面,进入页面后需要重新加载数据并刷新页面,而,每一次请求服务器再返回数据不仅用户体验不好,也花费手机流量 ...

  10. 【luogu P3879 [TJOI2010]阅读理解】 题解

    题目链接:https://www.luogu.org/problemnew/show/P3879 我先说一句: 我永远都喜欢StellaSTL 这个题,很明显就是 trie树 hash map+vec ...