public ActionResult Upload() { try { int id = 0; foreach (string file in Request.Files) { var currentFile = Request.Files[file]; var byteStream = _imageProcessor.GetImageByteArray(currentFile.InputStream); string fileName = currentFile.FileName; string contentType = currentFile.ContentType; var currentImage = new Image { FileName = fileName, Picture = byteStream, ImageType = contentType, IsShown = true }; this.images.Add(currentImage); this.images.SaveChanges(); id = currentImage.ID; } return(RedirectToAction("RenderImage", new { id = id })); } catch (Exception) { return(Json(false)); } }