Identity MVC:UI
基于原来做的cookie认证的代码:MvcCookieAuthSample


增加登陆和退出的方法:
增加Login和SignIn这两个Action方法。

在Views下面创建Account文件夹,然后在里面创建两个视图页面。
我是赋值下面的Privacy.cshtml页面到Account文件夹。然后改了名字为Register.cshtml和Login.cshtml这两个视图页面。


创建文件夹:ViewModels
再创建RegisterViewModel.cs


using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks; namespace MvcCookieAuthSample.ViewModels
{
public class RegisterViewModel
{
public string Email { get; set; }
public string Password { get; set; }</span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">string</span> ConfirmPassword { <span style="color: #0000ff;">get</span>; <span style="color: #0000ff;">set</span><span style="color: #000000;">; }
}
}
RegisterViewModel
Login.cshtml 简单的登陆页面

在布局页面 把登陆和注册也加上去

引入ViewModel的命名空间:
Register和Login的视图页面都要引用

<ul class="navbar-nav flex-grow-1">
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Home</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
</li><li <span style="color: #0000ff;">class</span>=<span style="color: #800000;">"</span><span style="color: #800000;">nav-item</span><span style="color: #800000;">"</span>>
<a <span style="color: #0000ff;">class</span>=<span style="color: #800000;">"</span><span style="color: #800000;">nav-link text-dark</span><span style="color: #800000;">"</span> asp-area=<span style="color: #800000;">""</span> asp-controller=<span style="color: #800000;">"</span><span style="color: #800000;">Account</span><span style="color: #800000;">"</span> asp-action=<span style="color: #800000;">"</span><span style="color: #800000;">Register</span><span style="color: #800000;">"</span>>Register</a>
</li>
<li <span style="color: #0000ff;">class</span>=<span style="color: #800000;">"</span><span style="color: #800000;">nav-item</span><span style="color: #800000;">"</span>>
<a <span style="color: #0000ff;">class</span>=<span style="color: #800000;">"</span><span style="color: #800000;">nav-link text-dark</span><span style="color: #800000;">"</span> asp-area=<span style="color: #800000;">""</span> asp-controller=<span style="color: #800000;">"</span><span style="color: #800000;">Account</span><span style="color: #800000;">"</span> asp-action=<span style="color: #800000;">"</span><span style="color: #800000;">Login</span><span style="color: #800000;">"</span>>Log <span style="color: #0000ff;">in</span></a>
</li> </ul></pre>
_Layout.cshtml菜单部分代码

运行我们的程序
Register页面

login的页面

Identity MVC:UI的更多相关文章
- 任务43: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 ...
- 43-Identity MVC:UI
1-打开之前写的MvcCookieAuthSample项目, 在AccountController新加Register,Login方法 public class AccountController : ...
随机推荐
- django中collectstatic的使用
前言 我最近在琢磨django框架的使用,在上传个人网站服务器上时,再次遇到了找不到静态文件,css.img等样式全无的问题.于是沉下心来,好好研究了django的静态文件到底应该怎么去部署(depl ...
- MyBatis体系学习总览
MyBatis特点:MyBatis是面向SQL的,核心是SQL结果和Map的映射.不要求一定与实体对象进行映射. MyBatis 可以使用 XML 或注解进行配置和映射, MyBatis 通过将参数映 ...
- web框架之初识Django
目录 一.web框架 1.1什么是web框架 1.2自制的简易web框架 1.3三大主流web框架简介 Django Flask Tornado 1.4动态网页与静态网页 二.初识Django框架 2 ...
- Baltic2014 sequence
问题描述 输入格式 输出格式 一个整数R 样例输入 7 9 4 8 20 14 15 18 样例输出 13 数据范围 所求的Z序列为6,7,8,13,14,15,18. R=13 解析&左偏树 ...
- list列表切片方法汇总
python为list列表提供了强大的切片功能,下面是一些常见功能的汇总 """ 使用模式: [start:end:step] 其中start表示切片开始的位置,默认是0 ...
- python全栈开发,Day40(进程间通信(队列和管道),进程间的数据共享Manager,进程池Pool)
昨日内容回顾 进程 multiprocess Process —— 进程 在python中创建一个进程的模块 start daemon 守护进程 join 等待子进程执行结束 锁 Lock acqui ...
- codeforces 848B - Rooter's Song(构造+几何)
原题链接:http://codeforces.com/problemset/problem/848/B 题意:好多个人分别从x,y轴不同位置不同时间往垂直坐标轴方向移动,一旦相遇他们转向,问所有人的到 ...
- (3.1)狄泰软件学院C++课程学习剖析二
深度剖析C++第二部分 1.通过对象名能够访问public成员变量.每个对象的成员变量都是专属的,成员变量不能够在对象之间共享. 2.需求:统计在程序运行期间某个类的对象数目,保证程序的安全性(不能使 ...
- H700关闭Direct PD Mapping
Attached Enclosure doesn't support in controller's Direct mapping modePlease contact your system sup ...
- ora4031
http://blog.itpub.net/23135684/viewspace-1203447/ Mon Sep 11 08:56:10 2017Errors in file /oracle/db/ ...