Informing ASP.NET website about the currently logged-in user

Arroneype

New Member
I'm new to ASP.NET and have been trying to solve this for awhile now.I've came across this blog, and everything looks to be good, except one thing: the below code always evaluates to false in \[code\]HttpContext.Current.User.Identity is FormsIdentity\[/code\] in this code snippit:\[code\]protected void Application_AuthenticateRequest(Object sender,EventArgs e){ if (HttpContext.Current.User != null) { if (HttpContext.Current.User.Identity.IsAuthenticated) { if (HttpContext.Current.User.Identity is FormsIdentity) { FormsIdentity id = (FormsIdentity)HttpContext.Current.User.Identity; FormsAuthenticationTicket ticket = id.Ticket; // Get the stored user-data, in this case, our roles string userData = http://stackoverflow.com/questions/14554494/ticket.UserData; string[] roles = userData.Split(','); HttpContext.Current.User = new GenericPrincipal(id, roles); } } }}\[/code\]When I used breakpoints, it turned that my PC name is the current user, which I think is not a \[code\]FormsIdentity\[/code\].Web.config:\[code\]<?xml version="1.0"?><!-- For more information on how to configure your ASP.NET application, please visit http://go.microsoft.com/fwlink/?LinkId=169433 --><configuration> <system.web> <compilation debug="true" targetFramework="4.0"/> </system.web></configuration>\[/code\]What am I missing here? and how to tell \[code\]HttpContext\[/code\] of the current user after a sucessful login?
 
Back
Top