添加在ASP.NET中的身份角色 [英] Add role in ASP.NET Identity

查看:87
本文介绍了添加在ASP.NET中的身份角色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎样才能在新的ASP.NET识别系统(1.0)添加一个角色?
有一个 UserStore 类,但没有 Rolestore的类。

我找不到任何关于此问题的文档。


解决方案

  RoleManager =新RoleManager< IdentityRole>(新Rolestore的< IdentityRole>(新MyDbContext()));
VAR roleresult = RoleManager.Create(新IdentityRole(角色名));

How can I add a Role in the new ASP.NET Identity system (1.0)? There is a UserStore class but no RoleStore class.

I can't find any documentation on this issue.

解决方案

RoleManager = new RoleManager<IdentityRole>(new RoleStore<IdentityRole>(new MyDbContext()));
var roleresult = RoleManager.Create(new IdentityRole(roleName));

这篇关于添加在ASP.NET中的身份角色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆