0

如果我创建一个具有五个自定义属性(例如 phoneNumber)的自定义主体,主体数据是在 cookie 中传输还是保留在服务器中?

void MvcApplication_AuthenticateRequest(object sender, EventArgs e)
    {
        if (HttpContext.Current.User != null)
        {
            if (HttpContext.Current.User.Identity.IsAuthenticated)
            {
                if (HttpContext.Current.User.Identity is FormsIdentity)
                {
                    // Get Forms Identity From Current User 
                    FormsIdentity id = (FormsIdentity)HttpContext.Current.User.Identity;
                    // Get Forms Ticket From Identity object 
                    FormsAuthenticationTicket ticket = id.Ticket;
                    // Create a new Generic Principal Instance and assign to Current User 
                    IFGPrincipal siteUser = new IFGPrincipal(Context.User.Identity, new string[] { }, 2);

                    HttpContext.Current.User = siteUser;
                }
            }
        } 

    }
4

0 回答 0