Upon each login in ASP.NET I place the users username in the session like this
//.....
if (PasswordHash.PasswordHash.ValidatePassword(LoginForm.Password, password))
{
e.Authenticated = true;
Session["Username"] = LoginForm.UserName;
}
//.....
Now I need to access that through JS and I thought I could just do this:
if (won) {
var username = '<%= Session["Username"] %>'
alert("Congrats " + username + ", you won!");
}
But I'm getting Congrats <%= Session["Username"] %>, you won!
instead. Why is that? Judging by answers in this and this question I should be able to access it like that.