title: How to pass Session data from controller to View (MVC)
body: <p>I'm new into MVC and I'm having a hard time solving this following issue. I got a userID via <code>Session["LoggedUserID"]</code> as it get once the user log in. I want to pass it to following cshtml code(<em>or directly in controller?</em>) which I do not understand for the moment. This action occur once user want to create a new post. </p>
  
  <p><em>inside cshtml view(code created automatically from Controller):</em></p>
  
  <pre><code>     @Html.ValidationSummary(true, "", new { @class = "text-danger" })
      &lt;div class="form-group"&gt;
          @Html.LabelFor(model =&gt; model.CreatorUserId, "CreatorUserId", htmlAttributes: new { @class = "control-label col-md-2" })
          &lt;div class="col-md-10"&gt;
              @Html.DropDownList("CreatorUserId", null, htmlAttributes: new { @class = "form-control" })
              @Html.ValidationMessageFor(model =&gt; model.CreatorUserId, "", new { @class = "text-danger" })
          &lt;/div&gt;
      &lt;/div&gt;
  </code></pre>
  
  <p><em>My controller code:</em> </p>
  
  <pre><code> [HttpGet]
          public ActionResult Create()
          {
              return View();
          }
  
  [HttpPost]
  public ActionResult Create(Review review)
  {  
      if (ModelState.IsValid) {
  
          db.Reviews.Add(review);
          db.SaveChanges();
  
          return RedirectToAction("Index");
      }
      return View(review);        
  }
  </code></pre>
  
  <p>How do I pass <code>Session["LoggedUserID"]</code> to cshtml (<em>or directly via controller</em>)? Review table is using userID as FK for user ID.</p>
  
  <p>EDIT: The error message I get for my current code is: </p>
  
  <blockquote>
    <p>There is no ViewData item of type 'IEnumerable' that
    has the key 'CreatorUserId'.</p>
  </blockquote>
  
  <p>Any help is much appreciated. Thanks.</p>