public ActionResult Create(HttpPostedFileBase file, ProductModel data) { Boolean result = false; try { if (file != null) { string path = Path.Combine(Server.MapPath("~/Content/Product_Images"), Path.GetFileName(file.FileName)); file.SaveAs(path); if (!string.IsNullOrWhiteSpace(path)) { data.ProductImage = "/Content/Product_Images/" + file.FileName; result = objBusiness.AddNewProduct(data); if (result) { ViewBag.Result = "SUCCESS: " + data.ProductName + " added successfully."; } else { ViewBag.Error = "Failure: Something went wrong."; } } } } catch (Exception ex) { throw ex; } return(View()); }