I am trying to access a session variable inside a MVC razor view, the session variable is of type User which has a property UserID, the code is like the following:
<h3>@((User)Session["LoggedOnUser"]).UserID</h3>
It only prints the fully qualified type of the property instead of its value. I also tried the following:
@{User loginUser = (User)Session["LoggedOnUser"];}
<h3>@loginUser.UserID</h3>
It works this time. Can anyone tell me what's the difference of these two and why the first one does not work?
Thanks.