}
"UserData"这里为 accountType. 不能为Null 否则 Encrypt的时候会为null.
//Global.asax
protected void Application_PostAuthenticateRequest(Object sender, EventArgs e)
{
HttpCookie authCookie = Request.Cookies[FormsAuthentication.FormsCookieName];
if (authCookie != null)
{
FormsAuthenticationTicket authTicket = FormsAuthentication.Decrypt(authCookie.Value);
if (authTicket != null && authTicket.UserData != null)
{
var rehauIdentity = new RehauIdentity(HttpContext.Current.User.Identity) {AccountType = authTicket.UserData};
HttpContext.Current.User = rehauIdentity;
}
}
}
//IdentityClass
public class RehauIdentity : IPrincipal
{
public IIdentity Identity { get; private set; }
public bool IsInRole(string role) { return Roles.IsUserInRole(Identity.Name, role); }
public RehauIdentity(IIdentity identity) { this.Identity = identity; }
public string AccountType { set; get; }
}
LeetCode:Binary Tree Postorder Traversal,布布扣,bubuko.com
LeetCode:Binary Tree Postorder Traversal
原文:http://blog.csdn.net/whu_sky/article/details/22376629