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. 函数名: lseek

    函数名: lseek 功 能: 移动文件读/写指针 头文件:#include <sys/types.h> #include <unistd.h> 用 法: off_t lsee ...

  2. bzoj3820 虫逢

    Description 小强和阿米巴是好朋友. 阿米巴告诉小强,变形虫(又叫阿米巴虫)和绝大多数生物一样,也是有 DNA 的.并且,变形虫可以通过分裂的方式进行无性繁殖. 我们把一个变形虫的基因组抽象 ...

  3. Windows XP和Wndows7误删除了注册表下.exe文件夹之修复办法

    在桌面空白处鼠标右击选择“新建-文本文档”,然后将下面的代码复制粘贴进去;如图所示: Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\. ...

  4. 三角测量(Triangulation)

    三角测量(Triangulation)是视觉定位中,已知多个相机位置和空间中一点的投影点,进一步求该点3D位置的方法.三角测量是Pose Estimation的相反过程,求出相机位置后,图像中其它特征 ...

  5. 【luogu P3389 高斯消元法】 模板

    题目链接: gauss消元求线性方程组的解. 这道题对于多解和无解都输出No solution #include <algorithm> #include <cstdio> # ...

  6. 解决Storm 和yarn 8080 端口冲突

    本机装了Yarn和Storm后,启动Storm后,发现NodeMange无法启动,找了下没找着在哪修改.只好修改Storm的配置,在配置上添加 ui.port: "9999" 再启 ...

  7. 微软.net framework 源码学习

    1. 直接下载.NET Framework源代码(下载地址),然后用Visual Studio打开查看. 2. 在线查看,网址:http://referencesource.microsoft.com ...

  8. gcc扩展语法一:在表达式中的语句和声明

    在GNU C中包含在括号中的复合语句可以作为一个表达式.这就允许你在表达式中使用循环,switch和局部变量. 以前复合语句是包含在大括号中语句序列.在这种构造中,圆括号包围在大括号中.如下面的例子: ...

  9. Java 加密Excel文件(打开时需输入密码)

    收集:author: lifq package com.XXX.XXX.utils; import java.io.IOException; import com.jxcell.CellExcepti ...

  10. ImportError: No module named lmdb

    why? 具体原因没有查清楚.安装caffe时,按照要求安装了包,caffe用的好好的,而且我也用打好包的lmdb跑了程序了.可我今天想看一下我的打包数据是不是漏掉数据了,直接开个python窗口,i ...