如何设置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。

转载于:https://www.cnblogs.com/Benjamin/archive/2012/10/30/2746925.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值