Im getting really lost on how to use HttpContext.User. I read everywhere that its great for FormAutherication, but i just cant see how it works. If i do something like this:
ControllerContext.HttpContext.User = new GenericPrincipal(GetUser(username, password), roles);
What does ControllerContext.HttpContext.User contain? and how do i access information about the user this way?
Im think that i have a Action like this:
public User GetUser(string username, string password)
{
try
{
var user = (from u in dm.Users
join r in dm.Roles
on u.Role_ID_FK equals r.RoleID
where u.Username.Equals(username) && u.Password.Equals(password)
select u).Single();
return user;
}
catch (Exception e)
{
return null;
}
}
And then if i want user information in my view, like the user name or role, i can call ControllerContext.HttpContext.User.Username in my View. But this is diffenrently the wrong way to look at it.
So can you guys give me a kick in the rigth direction or post a link to a site which can?