title: but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable`1[MvcApplication1.Models.FileStore]'
body: <p>I am following <a href="http://www.mikesdotnetting.com/Article/125/ASP.NET-MVC-Uploading-and-Downloading-Files" rel="nofollow">http://www.mikesdotnetting.com/Article/125/ASP.NET-MVC-Uploading-and-Downloading-Files</a>. Using VS2010, ASP.NET 4.0, MVC3 in C# with ADO.NET in SQL Server 2008R2. I am getting the following error message...</p>
  
  <p><em>The model item passed into the dictionary is of type 'MvcApplication1.Models.FileStore', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable<code>1[MvcApplication1.Models.FileStore]'.
  Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
  Exception Details: System.InvalidOperationException: The model item passed into the dictionary is of type 'MvcApplication1.Models.FileStore', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable</code>1[MvcApplication1.Models.FileStore]'.
  Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.</em></p>
  
  <p>I am little concern I may have got my Index method wrong. Thanks in advance if anyone can tell me the solution this problem. </p>
  
  <p>Index method in the controller has the following code...</p>
  
  <pre><code> FileStore db = new FileStore();
  
      public ActionResult Index()
      {
          var db = new FileStore();
          return View(db);
      }
  </code></pre>
  
  <p>Create method  in the controller has the following method...</p>
  
  <pre><code> public ActionResult Create()
      {
          foreach (string upload in Request.Files)
          {
              if (!Request.Files[upload].HasFile()) continue;
  
              string mimeType = Request.Files[upload].ContentType;
              Stream fileStream = Request.Files[upload].InputStream;
              string fileName = Path.GetFileName(Request.Files[upload].FileName);
              int fileLength = Request.Files[upload].ContentLength;
              byte[] fileData = new byte[fileLength];
              fileStream.Read(fileData, 0, fileLength);
  
              const string connect = @"Server=.\SQLExpress;Database=FileTest;Trusted_Connection=True;";
              using (var conn = new SqlConnection(connect))
              {
                  var qry = "INSERT INTO FileStore (FileContent, MimeType, FileName) VALUES (@FileContent, @MimeType, @FileName)";
                  var cmd = new SqlCommand(qry, conn);
                  cmd.Parameters.AddWithValue("@FileContent", fileData);
                  cmd.Parameters.AddWithValue("@MimeType", mimeType);
                  cmd.Parameters.AddWithValue("@FileName", fileName);
                  conn.Open();
                  cmd.ExecuteNonQuery();
              }
          }
          return View();
      }
  </code></pre>
  
  <p>and GetFile method has the following code...</p>
  
  <pre><code> public FileContentResult GetFile(int id)
      {
          SqlDataReader rdr; byte[] fileContent = null;
          string mimeType = ""; string fileName = "";
          const string connect = @"Server=.\SQLExpress;Database=FileTest;Trusted_Connection=True;";
  
          using (var conn = new SqlConnection(connect))
          {
              var qry = "SELECT FileContent, MimeType, FileName FROM FileStore WHERE ID = @ID";
              var cmd = new SqlCommand(qry, conn);
              cmd.Parameters.AddWithValue("@ID", id);
              conn.Open();
              rdr = cmd.ExecuteReader();
              if (rdr.HasRows)
              {
                  rdr.Read();
                  fileContent = (byte[])rdr["FileContent"];
                  mimeType = rdr["MimeType"].ToString();
                  fileName = rdr["FileName"].ToString();
              }
          }
          return File(fileContent, mimeType, fileName);
      }
  </code></pre>
  
  <p>Index.cshtml like has the following code...</p>
  
  <pre><code>@model IEnumerable&lt;MvcApplication1.Models.FileStore&gt;
  </code></pre>