Gcobani Mkontwana

Gcobani Mkontwana

  • 1k
  • 1.4k
  • 192.7k

System.ArgumentNullException: 'Value cannot be null. Parameter name: e

Aug 31 2020 4:56 AM
Hi Team
 
I need some help with this exception, value cannot be empty. This is what i have on my application;
  1. // Model  
  2.   public class eNtsaCourses  
  3.     {  
  4.         [Key]  
  5.         public Guid? Id { getset; }  
  6.         public string Course { getset; }  
  7.         public string Nickname { getset; }  
  8.         public string Term { getset; }  
  9.         public string EnrolledAs { getset; }  
  10.         public bool Published { getset; }  
  11.     }  
  12.   
  13. // Controller  
  14.     //GET://Courses/Courses-All.  
  15.         [Route("Home/Courses")]  
  16.       public ActionResult Courses(RegCoursesViewModel eNtsaCourses)  
  17.         {  
  18.             if(ModelState.IsValid)  
  19.             {  
  20.                 cb.eNtsaCourse.Add(eNtsaCourses.Courses);   
  21.                 cb.SaveChanges(); // This throws an exception here  
  22.             }  
  23.             return View(eNtsaCourses);  
  24.         }  
  25.   [HttpPost]  
  26.         public JsonResult AddCoursesRegistration(string CourseName, string clientNo)  
  27.         {  
  28.             return Json(true, JsonRequestBehavior.AllowGet);  
  29.         }  
 

Answers (3)