title: session bind with @Html.DropDownListFor
body: <p>I have one of a method as following in my controller</p>
  
  <p>Code</p>
  
  <pre><code>        var companies = ...
          List&lt;CompanyModel&gt; listOfCompanies = new List&lt;CompanyModel&gt;();
  
          foreach (var item in companies)
          {
               listOfCompanies.Add(new CompanyModel(item.CompanyId, item.CompanyName));
          }
  
          ViewBag.Company = listOfCompanies;
  </code></pre>
  
  <p>View page</p>
  
  <pre><code> @Html.DropDownListFor(m =&gt; m.Company, new SelectList(ViewBag.Company, "id", "name"), "Select company", new { @class = "form-control" })
  </code></pre>
  
  <p>this is working fine , I'm trying trying to use session instead of viewbag here. </p>
  
  <p>So for that I did</p>
  
  <pre><code>        var companies = ...
          List&lt;CompanyModel&gt; listOfCompanies = new List&lt;CompanyModel&gt;();
  
          foreach (var item in companies)
          {
              listOfCompanies.Add(new CompanyModel(item.CompanyId, item.CompanyName));
          }
  
          Session["CompanyData"] = listOfCompanies;
  </code></pre>
  
  <p>View page </p>
  
  <pre><code>  @Html.DropDownListFor(m =&gt; m.Company, new SelectList(Model.Company, "id", "name", Session["CompanyData"]), "Select company", new { @class = "form-control" })
  </code></pre>
  
  <p>but this is not working properly, whats the path to achieve this</p>