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. 深入Python(1): 字典排序 关于sort()、reversed()、sorted()

    http://www.cnblogs.com/BeginMan/p/3193081.html 一.Python的排序 1.reversed() 这个很好理解,reversed英文意思就是:adj. 颠 ...

  2. March 16 2017 Week 11 Thursday

    Adventure may hurt you, but monotony will kill you. 也许冒险会让你受伤,但一成不变会让你灭亡. The very theme of the univ ...

  3. OOA-OOD—OOP

    关于面向对象(OO)程序设计的思想,现在把它记下来. ----OOA Object-Oriented Analysis(面向对象分析方法)是确定需求或者业务的角度,按照面向对象的思想来分析业务.例如: ...

  4. python入门14 字典dict

    字典dict是无序的key:value格式的数据序列 #coding:utf-8 #/usr/bin/python """ 2018-11-11 dinghanhua 字 ...

  5. Ubuntu 配置java环境变量

    1.使用如下命令,打开/etc/profile: $sudo vi /etc/profile 2.进入编辑模式,在末尾添加: #developer enviroment, add by myself ...

  6. 设计模式——原型模式(Prototype Pattern)

    原型模式:用原型实例制定创建对象的种类,并且通过拷贝这些原型创建新的对象. UML 图: 原型类: package com.cnblog.clarck; /** * 原型类 * * @author c ...

  7. 计算次数,POJ(1207)

    题目链接:http://poj.org/problem?id=1207 #include <stdio.h> #include <algorithm> using namesp ...

  8. Git免密码提交

    下面说一下https克隆的方式免密码提交 在我们下载链接前面加上账号:密码@即可 方式一: 使用https的方式克隆代码 git clone '地址' 查看项目中的配置文件 vim .git/conf ...

  9. Angularjs实例5

    <!DOCTYPE html><html lang="zh-cn" ng-app="myApp"><head><met ...

  10. 29.You executed the following command to perform a backup of the USERS tablespace:

    29.You executed the following command to perform a backup of the USERS tablespace:SQL> ALTER TABL ...