c# - What is the overhead on PostAuthenticateRequest? -
i implementing custom ticket system using application_postauthenticaterequest method in global.asax file (asp.net mvc). i'm wondering overhead kind of thing - since deserialize information on every request. generates cookie of around 1.8 kb, ton - better alternative frequent database trips?
information being deserialized
- user id (int)
 - roles (string[])
 - email (string)
 - associated ids (int[]) // (hard describe these are, each user have around 3 of them)
 
it seemed smarter implement custom formsauthenticationticket system continuously round-trips database based on user.identity.name. i'm worried constant deserialization inhibitive. looks this...
    protected void application_postauthenticaterequest(object sender, eventargs e)     {         httpcookie authcookie = httpcontext.current.request.cookies[formsauthentication.formscookiename];          if (authcookie != null)         {             string encticket = authcookie.value;              if (!string.isnullorempty(encticket))             {                 // decrypt ticket if possible.                 formsauthenticationticket ticket = formsauthentication.decrypt(encticket);                  var userdata = deserializer.deserialize(ticket);                 userprincipal principal = new userprincipal(userdata);                  httpcontext.current.user = principal;             }         }     }   here class being serialized userdata in formsauthenticationticket.
[serializable] public class membershipdata {     public string email     {         get;         set;     }      public int id     {         get;         set;     }      public string[] roles     {         get;         set;     }      public int[] ancillary     {         get;         set;     } }      
i recommend measuring performance expect cookie approach faster doing roundtrips database. simplify serialization , make fast possible using comma delimited or special character delimited string. here how rank different operations in terms of performance:
- in-process communication
 - inter-process communication
 - inter-network communication
 
Comments
Post a Comment