title: Retrieve Session variables into ASP.NET MVC 4 (razor, view)
body: <p>I wrote many websites with PHP. Now, I have to create website with ASP MVC 4 (c#) and I am stuck with Sessions.</p>
  
  <p>I.E. the user should go to login page, enter his/her login and password. If they are correct, in controller, I set the session with UserId, like this: </p>
  
  <pre><code>Session["UserId"] = 10
  </code></pre>
  
  <p>This UserId value is used for showing PartialViews (login form or (after login) some application menus). How can I get this UserId inside Razor view ? </p>
  
  <p>After this in View:</p>
  
  <pre><code>if (Session.UserId == 10) { @Html.Partial("LoggedMenu") }
  </code></pre>
  
  <p>i've got exception with StackOverflow. :/</p>