关于Forms验证中User.IsInRole()求教
我想用User.IsInRole()方法。在通过FormsAuthenticationTicket后,我不知道怎么向User里添加role。
我现在是这样做的:
string [] role = ticket.UserData.Split(',');
HttpContext.Current.User = new System.Security.Principal.GenericPrincipal(User.Identity,role);
但是:
debug的时候发现这个User的IsAuthenticated为false。在其它页面上User的role还是没有。感觉虽然重新构造了User,但后续的使用中,并没有接纳它,只能使用User.Identity.Name