Expert,
In one application, they are using framework dll in project. The framework project is handling the global.asax and Form authentication.
Any how i am not sure that sometimes form authentication is not working.
so, I use my code in web project is as follows:
But it throwing error "object reference .." from context.User = new System.Security.Principal.GenericPrincipal(new System.Web.Security.FormsIdentity(ticketData), null);Code:System.Web.Security.FormsAuthenticationTicket ticket = new System.Web.Security.FormsAuthenticationTicket(1, userName, DateTime.Now, DateTime.Now.AddMinutes(50), false, userName); string hashCookies = System.Web.Security.FormsAuthentication.Encrypt(ticket); HttpCookie cookie = new HttpCookie(System.Web.Security.FormsAuthentication.FormsCookieName, hashCookies); // Hashed ticket // Add the cookie to the response, user browser Response.Cookies.Add(cookie); HttpApplication application = new HttpApplication(); HttpContext context = application.Context; System.Web.Security.FormsAuthenticationTicket ticketData = System.Web.Security.FormsAuthentication.Decrypt(cookie.Value); if (null != ticketData && !ticketData.Expired) { context.User = new System.Security.Principal.GenericPrincipal(new System.Web.Security.FormsIdentity(ticketData), null); context.Items.Add(userName, ticketData.UserData); }
anmyone please help me out.
Thanks.
Ujjwal Das


Reply With Quote
Bookmarks