validate uploaded image wrt size, format in asp.net mvc5
[HttpPost] [ValidateAntiForgeryToken] public ActionResult Create(Model argModel, HttpPostedFileBase file) { string msg = Utilities.IsImageValid(file); if (!msg.Trim().Equals("ok")) { ModelState.AddModelError("", msg); } if (ModelState.IsValid) { //saving here return View("Index"); } return View("Create", argModel); } public class Utilities { public static string IsImageValid(object value) { var file = value as HttpPostedFileBase; if (file == null) { return "Please attach photograph."; } ...