public ActionResult FileUpload(HttpPostedFileBase file, int productId, int imageCategory) { if (file == null) { TempData["bad"] = "Choose image!"; return(RedirectToAction("Edit", new { id = productId })); } var productImage = new ProductImage(); productImage.CreateImage(productId, blob.GetUrl(), imageCategory); blob.SaveImage(productImage, file); repository.ProductImages.Add(productImage); repository.SaveChanges(); TempData["good"] = "Image uploaded"; return(RedirectToAction("Edit", new { id = productId })); }