0

If i create a custom principal with five custom properties (example, phoneNumber), does the principal data get trasmitted inside of the cookie or does the data stay in the server?

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;
                }
            }
        } 

    }
Tony
  • 21
  • 4
  • How are you creating this custom principal? – Darin Dimitrov Sep 13 '11 at 21:45
  • Thanks Darin, Here is the debate. Does the pricipal remain througout the whole session life or is it created every time there is a request AND does it get populated from the data that is store in the cookie automatically. – Tony Sep 13 '11 at 21:52
  • this will depend on how you implement it. You still didn't answer my question. – Darin Dimitrov Sep 13 '11 at 21:53
  • i edited my initial post with the code. – Tony Sep 13 '11 at 22:00
  • you have shown only the part of the code which deals with authenticated users. You haven't shown how you are authenticating your users and how you are emitting the authentication cookie. For example you could use the userData part of this authentication cookie to store additional profile settings when a user logs in and in your MvcApplication_AuthenticateRequest method read this information and assign it to your custom profile. – Darin Dimitrov Sep 13 '11 at 22:03

0 Answers0