public ActionResult Create(News news, HttpPostedFileBase fileAvatar) { NewsContext newsBL = new NewsContext(); if (fileAvatar == null) { return(RedirectToAction("Index")); } String nameFile = System.IO.Path.GetFileName(fileAvatar.FileName); news.Avatar = nameFile; if (newsBL.Create(news) > 0) { string SaveLocation = Server.MapPath("~/Content/imgs") + "\\" + nameFile; try { fileAvatar.SaveAs(SaveLocation); } catch (Exception ex) { Response.Write("Error: " + ex.Message); } } return(RedirectToAction("Index")); }