【发布时间】:2011-04-20 18:33:08
【问题描述】:
使用此代码进行身份验证:
HttpContext.Current.User=new GenericPrincipal
(new GenericIdentity(user.UserName), roles);
FormsAuthentication.SetAuthCookie(user.UserName,false);
问题是 - 在下一个请求中,HttpContext.Current.User.IsAuthenticated 是 true,但 HttpContext.Current.User.IsInRole("admin") 是错误的。
谷歌上有一个lot of info,但不知何故没有像往常一样有帮助。
尝试将此添加到我的 web.config:
<system.web>
<roleManager enabled="false" />
</system.web>
我不想使用会员提供者。
有什么建议吗?
【问题讨论】:
-
你使用什么样的角色提供者?
-
blind rabbit mode ON 抱歉,我在这里度过了一个艰难的下午 :d Reflector 说你做得对......也许你应该仔细检查一下你的角色字符串数组
标签: asp.net asp.net-mvc security forms-authentication