public ActionResult Edit(string id, ATour tour, HttpPostedFileBase image) { try { if (ModelState.IsValid) { if (image != null) { tour.ImageMimeType = image.ContentType; tour.ImageData = new byte[image.ContentLength]; image.InputStream.Read(tour.ImageData, 0, image.ContentLength); } BTourGuideOp tourOp = new BTourGuideOp(); tour.TourID = id; tourOp.EditTour(tour); return RedirectToAction("Index"); } else { tour.TourID = id; // important to get the image return View(tour); } } catch (Exception e) { TempData["EditException"] = "Error in tour edit: " + e.Message; return View(tour); } }