• 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>
    
                        &lt;li <span style="color: #0000ff;">class</span>=<span style="color: #800000;">"</span><span style="color: #800000;">nav-item</span><span style="color: #800000;">"</span>&gt;
                            &lt;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>&gt;Register&lt;/a&gt;
                        &lt;/li&gt;
                        &lt;li <span style="color: #0000ff;">class</span>=<span style="color: #800000;">"</span><span style="color: #800000;">nav-item</span><span style="color: #800000;">"</span>&gt;
                            &lt;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>&gt;Log <span style="color: #0000ff;">in</span>&lt;/a&gt;
                        &lt;/li&gt;
                     
                    &lt;/ul&gt;</pre>
    
    _Layout.cshtml菜单部分代码

    运行我们的程序

    Register页面

    login的页面

  • 相关阅读:
    spring FactoryBean配置Bean
    注意使用 BTREE 复合索引各字段的 ASC/DESC 以优化 order by 查询效率
    Mysql经常使用基本命令汇总及默认账户权限与改动
    图像边缘检測--OpenCV之cvCanny函数
    HDU 1556 Color the ball 树状数组 题解
    JMeter使用记录2 -- Web測试
    C++编程
    矩阵树定理速证
    DM816x算法具体解释--之OSD
    哥尼斯堡的“七桥问题”(25分)(欧拉回路,并查集)
  • 原文地址:https://www.cnblogs.com/owenzh/p/11301638.html
Copyright © 2020-2023  润新知