I was trying to set a session in mvc to store the current user that visited the site. For example:
A user visits the site.
It gets recorded to the database as a login.
When the user closes his browser. The session is over.
With Windows Authentication I can get the user name with this
User.Identity.Name
In the _layout I was hoping I could do this:
@{
var Data = HttpContext.Current.Session["UserSession"];
Data["UserSession"] = User.Identity.Name;
}
But I cant. What is the proper syntax to set up a session variable and assing it a value of my user’s identity.
If thats not what you need then i need more clarification on what your asking