title: The ViewData item that has the key 'Key' is of type 'System.Int32' but must be of type 'IEnumerable<SelectListItem>' in iis7.5
body: <p><strong>Solved - Check comments</strong></p>
  
  <p>I have a problem when I deploy my code to IIS 7.5, The code works fine in localhost but crashes when I deploy it.</p>
  
  <p>I have two methods that are almost exactly the same where one of them works both in localhost and IIS and one only works in localhost</p>
  
  <p><strong>Works in IIS 7.5 and localhost</strong></p>
  
  <p><strong>Controller</strong></p>
  
  <pre><code>var CustomerList = (from Cust in db.Customers
                     select Cust).ToList();
  ViewBag.CustomerList = new SelectList(CustomerList, "CustomerId", "Name");
  </code></pre>
  
  <p><strong>View</strong></p>
  
  <pre><code>@Html.DropDownListFor(m =&gt; m.CustomerId, ViewBag.CustomerList as SelectList, "-Select Customer-", new { id = "CustomerList" })
  </code></pre>
  
  <p><strong>Model</strong></p>
  
  <pre><code>    using System;
      using System.Collections.Generic;
  
      public partial class Customer
      {
          public Customer()
          {
              this.Applications = new HashSet&lt;Application&gt;();
              this.ChangeRequests = new HashSet&lt;ChangeRequest&gt;();
              this.Contacts = new HashSet&lt;Contact&gt;();
          }
  
          public int CustomerId { get; set; }
          public string Name { get; set; }
          public string Address { get; set; }
          public string ZipCode { get; set; }
          public string City { get; set; }
          public Nullable&lt;bool&gt; Active { get; set; }
  
          public virtual ICollection&lt;Application&gt; Applications { get; set; }
          public virtual ICollection&lt;ChangeRequest&gt; ChangeRequests { get; set; }
          public virtual ICollection&lt;Contact&gt; Contacts { get; set; }
      }
  </code></pre>
  
  <p>.</p>
  
  <p>.</p>
  
  <p><strong>Don't Work in IIS 7.5 but works in localhost</strong></p>
  
  <p><strong>Controller</strong></p>
  
  <pre><code>var ModificationList = (from m in db.Modifications
                          select m).ToList();
  ViewBag.ModificationList = new SelectList(ModificationList, "ModificationId", "Code");
  </code></pre>
  
  <p><strong>View</strong></p>
  
  <pre><code>@Html.DropDownListFor(m =&gt; m.ModificationId, ViewBag.ModificationList as SelectList, "-Select Change-", new { id = "ModificationList" })
  </code></pre>
  
  <p><strong>Model</strong></p>
  
  <pre><code>    using System;
      using System.Collections.Generic;
  
      public partial class Modification
      {
          public Modification()
          {
              this.ChangeRequests = new HashSet&lt;ChangeRequest&gt;();
          }
  
          public int ModificationId { get; set; }
          public string Code { get; set; }
          public string Description { get; set; }
  
          public virtual ICollection&lt;ChangeRequest&gt; ChangeRequests { get; set; }
      }
  </code></pre>
  
  <p><strong>The Error I get when trying to enter the deployed site</strong></p>
  
  <pre><code>&gt; The ViewData item that has the key 'ModificationId' is of type 'System.Int32' but must be of type 'IEnumerable&lt;SelectListItem&gt;'. 
  </code></pre>
  
  <p>.</p>
  
  <pre><code>&gt; [InvalidOperationException: The ViewData item that has the key 'ActionId' is of type 'System.Int32' but must be of type 'IEnumerable&lt;SelectListItem&gt;'.]
     System.Web.Mvc.Html.SelectExtensions.GetSelectData(HtmlHelper htmlHelper, String name) +442
     System.Web.Mvc.Html.SelectExtensions.SelectInternal(HtmlHelper htmlHelper, ModelMetadata metadata, String optionLabel, String name, IEnumerable`1 selectList, Boolean allowMultiple, IDictionary`2 htmlAttributes) +186
     System.Web.Mvc.Html.SelectExtensions.DropDownListFor(HtmlHelper`1 htmlHelper, Expression`1 expression, IEnumerable`1 selectList, String optionLabel, IDictionary`2 htmlAttributes) +136
     ASP._Page_Views_ChangeRequest_CreateChangeView_cshtml.Execute() in d:\WebSites\TeamWeb\ChangeRequestSite\Test\Views\ChangeRequest\CreateChangeView.cshtml:153
     System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +280
     System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +125
     System.Web.WebPages.StartPage.ExecutePageHierarchy() +143
     System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +181
     System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +380
     System.Web.Mvc.&lt;&gt;c__DisplayClass1a.&lt;InvokeActionResultWithFilters&gt;b__17() +33
     System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +613
     System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +613
     System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +263
     System.Web.Mvc.Async.&lt;&gt;c__DisplayClass25.&lt;BeginInvokeAction&gt;b__22(IAsyncResult asyncResult) +240
     System.Web.Mvc.&lt;&gt;c__DisplayClass1d.&lt;BeginExecuteCore&gt;b__18(IAsyncResult asyncResult) +28
     System.Web.Mvc.Async.&lt;&gt;c__DisplayClass4.&lt;MakeVoidDelegate&gt;b__3(IAsyncResult ar) +15
     System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +53
     System.Web.Mvc.Async.&lt;&gt;c__DisplayClass4.&lt;MakeVoidDelegate&gt;b__3(IAsyncResult ar) +15
     System.Web.Mvc.&lt;&gt;c__DisplayClass8.&lt;BeginProcessRequest&gt;b__3(IAsyncResult asyncResult) +42
     System.Web.Mvc.Async.&lt;&gt;c__DisplayClass4.&lt;MakeVoidDelegate&gt;b__3(IAsyncResult ar) +15
     System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +606
     System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp; completedSynchronously) +288
  </code></pre>