IIdentity id = HttpContext.User.Identity;GenericPrincipal MyPrincipal = new GenericPrincipal(id, role);HttpContext.User = MyPrincipal;這是登錄時的代碼,這里的User里的Roles有寫進去的角色。但是在view里@if(HttpContext.Current.User.IsInRole("管理員")){ @HttpContext.Current.User.Identity <br /> <h1>4</h1>}這是的User里就沒有寫進去的Roles了,這是因為什么呢??
- 2 回答
- 0 關注
- 431 瀏覽
添加回答
舉報
0/150
提交
取消