2010-05-11 4 views
1

사용자 지정 작성 로그인이있는 mvc 1.0 응용 프로그램을 업그레이드하려고합니다. 내가 _roles = "관리자"asp.net 2.0 사용자 지정 인증이 작동하지 않습니다.

를 가지고 디버깅 할 때

string _roles = string.Join(",", _ugr.GetUsergroupRoles(_username)); 

FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(
     1, 
     _username, 
     DateTime.Now, 
     DateTime.Now.AddHours(1), 
     false, 
     _roles, 
     "/"); 

HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(authTicket)); 
      HttpContext.Response.Cookies.Add(cookie); 

그리고 나는 내가 가지고있는 OnExecuting을 겹쳐 actionfilter 있습니다 :이 같은 authcookie를 할당 여기

.. 
string[] _authRoles = AuthRoles.Split(','); 

bool isAuthorized = _authRoles.Any(r => filterContext.HttpContext.User.IsInRole(r)); 

if (!isAuthorized) 
{ 
.. 

그리고 만약을 내가 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 여기서 _

"티켓"을 확인하면 다음과 같이 표시됩니다. UserData = "Admin".

무엇이 잘못 될 수 있습니까? 그것은 "User.IsInRole"이 다른가, 아니면 web.config에 뭔가를 추가해야합니까?

/M

답변

관련 문제