public ActionResult NewProduct(ProductsModel model) { if (ModelState.IsValid) { model.productimageaddress = "/Images/" + Guid.NewGuid() + ".jpg"; model.productimagefile.SaveAs(Server.MapPath(model.productimageaddress)); ProductDAL dal = new ProductDAL(); int id = dal.Addproduct(model); ViewBag.msg = "Product Added: " + id; ModelState.Clear(); ViewBag.category = dal.Getcategory(); return(View()); } else { ProductDAL dal = new ProductDAL(); ViewBag.category = dal.Getcategory(); return(View()); } }