Posted on: 3/26/2014 6:05:55 PM | Views : 754

Hi All,
I have one doubt regarding below code, It is good we are checking the authentication and if he is not authenticated then redirected to login page. But Why we are creating generic principal here and again updating the user ?. I am storing custom data in user data property (username, email, img).

protected void Application_OnAuthenticateRequest(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; // Retrieve stored user-data (role information is assigned // when the ticket is created) string userData = ticket.UserData; ...

Go to the complete details ...