43-Identity MVC:UI
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的更多相关文章
- 任务43:Identity MVC:UI
基于原来做的cookie认证的代码:MvcCookieAuthSample 增加登陆和退出的方法: 增加Login和SignIn这两个Action方法. 在Views下面创建Account文件夹,然后 ...
- Identity MVC:UI
基于原来做的cookie认证的代码:MvcCookieAuthSample 增加登陆和退出的方法: 增加Login和SignIn这两个Action方法. 在Views下面创建Account文件夹,然后 ...
- 任务45:Identity MVC:注册逻辑实现
任务45:Identity MVC:注册逻辑实现 做登陆 在注册成功直接进行登陆,使用SignIn 这里的signIn实际上是HttpContext.Signin的封装 await _signMana ...
- 任务46:Identity MVC:登录逻辑实现
任务46:Identity MVC:登录逻辑实现 实现登陆的方法 退出方法 _layout里面增加如下的代码: Login.cshtml 运行代码测试: 这个地方的单词之前拼错了.这里进行修正 输入账 ...
- 任务47:Identity MVC:ReturnUrl实现
任务47:Identity MVC:ReturnUrl实现 在最上面加一个私有的方法 登陆也加上returnUrl Login的post方法.加入returnUrl的参数 登陆界面也需要加上 asp- ...
- 任务48:Identity MVC:Model后端验证
任务48:Identity MVC:Model后端验证 RegisterViewModel using System; using System.Collections.Generic; using ...
- 任务49:Identity MVC:Model前端验证
任务49:Identity MVC:Model前端验证 前端验证使用的是jquery的validate的组件 _ValidationScriptsPartial.cshtml 在我们的layout里面 ...
- 任务50:Identity MVC:DbContextSeed初始化
任务50:Identity MVC:DbContextSeed初始化 首先添加seed 每次应用程序启动,监测一下,是否是第一次启动.如果是第一次执行,我们需要在数据库内添加一个记录 比如说我们的用户 ...
- 任务44:Identity MVC: EF + Identity实现
使用VSCode开发 Razer的智能感知不好.所以这里切换为VS2017进行开发: 新建一个Data的文件夹来存放我们的DBContext.在Data文件夹下新建: ApplicationDbCon ...
随机推荐
- 收放卷及张力控制 PID调试技巧
1) 小 Kp( 0.01) , 大 Ti ( 20000ms) 2)逐渐增大Kp, 减小Ti ( 20000ms – 3000ms),避免发生震荡 3)观察I-out 是否在0附近 可能原因:卷径不 ...
- Android(java)学习笔记46:反射机制
1. 反射机制: JAVA反射机制是在运行状态中,对于任意一个类,都能够知道这个类的所有属性和方法:对于任意一个对象,都能够调用它的任意一个方法和属性:这种动态获取的信息以及动态调用对象的方法的功能称 ...
- cocos2dx-打敌人游戏(一)
參照视频: http://v.youku.com/v_show/id_XNjk5MzExNDYw.html 1.參照前一篇文章创建新项目: http://blog.csdn.net/simakongc ...
- 郑州Day6
今天考了毕姥爷的一套题,差点保龄 题目 挺良心的一套题,至少我不用再搬一遍题面了 T1.B君的第一题 我为什么当时去写了一个树形\(dp\)还妄图\(A\)掉啊 这题保龄感觉舒爽 首先如果我们要求的是 ...
- Class<T>和Class<?>区别
Class<T>在实例化的时候,T要替换成具体类Class<?>它是个通配泛型,?可以代表任何类型
- spring boot Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration
java.lang.IllegalStateException: Unable to find a @SpringBootConfiguration, you need to use @Context ...
- JavaScript 经典实例日常收集整理(常用经典)
作者:阿讯小飞 原文来自:脚本之家 跨浏览器添加事件 //跨浏览器添加事件 function addEvent(obj,type,fn){ if(obj.addEventListener){ obj. ...
- 第13章 GPIO输入—按键检测
本章参考资料:<STM32F76xxx参考手册>.库帮助文档<STM32F779xx_User_Manual.chm>. 按键检测使用到GPIO外设的基本输入功能,本章中不再赘 ...
- java遍历文件夹两种方式
1:非递归方式(有点类似二叉树的非递归遍历,采用链表来存储遍历到的文件夹,如果是文件就直接输出) public void traverseFile(String path){ File[] files ...
- JS JavaScript事件循环机制
区分进程和线程 进程是cpu资源分配的最小单位(系统会给它分配内存) 不同的进程之间是可以同学的,如管道.FIFO(命名管道).消息队列 一个进程里有单个或多个线程 浏览器是多进程的,因为系统给它的进 ...