Nikita

Nikita

  • NA
  • 56
  • 10.1k

asp.net mvc . my program is not working .please solve my err

Dec 3 2019 5:58 AM
 
when i tried to run it it faces the error like "

CS0161 C# : not all code paths return a value

"  please suggest me the way that it can solve my error
 
 
 
 
[HttpPost]
public ActionResult Create(Student s)
{
if(ModelState.IsValid==true)
{
db.Students.Add(s);
int a = db.SaveChanges();
if (a > 0)
{
//ViewBag.InsertMessage = "<script>alert('Dta Inserted Successfully...!!!')</script>";
TempData["InsertMessage"] = "<script>alert('Dta Inserted Successfully...!!!')</script>";
return RedirectToAction("Index");
}
else
{
ViewBag.InsertMessage = "<script>alert('Dta Not Inserted Successfully...!!!')</script>";
return View();
}
}
}
 
 
 
 
 
 

Answers (4)