zoukankan      html  css  js  c++  java
  • 如何设置mvc的role和user

    1、总算将《css设计彻底研究》扫了一遍。以后专心后台。

    2、

    Css中的颜色表示法:六种

    color:blue;

    color:#0000ff;

    color:#00f;(上一种的缩写)

    color:rgb(0,0,255);

    color:rgb(0%,0%,100%);

    加粗:font-weight:normal   //正常

          font-weight:bold     //加粗

    倾斜的两种方式:italic,oblique

    分别是font-style:oblique,font-style:italic

     但是在windows中,两种倾斜的方式看起来效果是一样的。

    3、如何实现角色和成员管理

    在一个类或方法(一般使用方法)上设置 Authorize 特性,再加上参数,如

    [Authorize(Roles = ("Admin,SuperAdmin"),(Users="Jack,Tom"))] 

    用户就是注册时的用户,这个比较好设置。而Roles则必须写一个类,继承抽象类System.Web.Security.RoleProvider,并重写里面的方法,特别是GetRolesForUser和IsUserInRole。例如:

           public override string[] GetRolesForUser(string username)
            {
                List<string> roles = new List<string>();
    
                var admin = new AdminBLL().GetByWWId(username);
    
                if (admin != null)
    
                {
                    roles.Add(admin.TypeId);
                    return roles.ToArray();
                }
    
                var boss = new BossBLL().GetByWWID(username);
                if (boss != null && boss.WWId != string.Empty)
                {
                    roles.Add("Boss");
                }
                return roles.ToArray();
            }
            public override bool IsUserInRole(string username, string roleName)
            {
                var admin = new AdminBLL().GetByWWId(username);
                if (admin != null)
                {
                    return admin.TypeName == roleName;
                }
                else
                {
                    var boss = new BossBLL().GetByWWID(username);
                    if (boss != null)
                    {
                        return roleName == "Boss";
                    }
                    else
                    {
                        return false;
                    }
                }
            }

    4、当用ViewBag传值时,在后台可以不做非空判断l。渲染到前台后,如果没有相应的值,其值为null。

  • 相关阅读:
    c语言网络编程过程及函数说明
    c代码编译完整过程详解
    const关键字的常见作用
    c语言中static关键字的几个作用
    c语言结构体中字节对齐方式
    modbus协议数据格式
    CodeForces
    如何在Dev-Cpp中使用C++11中的函数:stoi、to_string、unordered_map、unordered_set、auto
    关于lower_bound( )和upper_bound( )的常见用法
    CodeForces 600C——思维
  • 原文地址:https://www.cnblogs.com/Benjamin/p/2746925.html
Copyright © 2011-2022 走看看