System.ArgumentNullException: Value cannot be null. Parameter name: source

Seats will be null if you call the method without matching data / query argument. You need to also check that, like so for instance:

[HttpPost]
public String Indexhome( IEnumerable<Seat>  Seats )
{
     if ((Seats == null) || !Seats.Any(s => s.IsSelected))
     {
            return "you didnt select any seats";
     }
     else
     {
           return "you selected " + string.Join(", ", Seats.Where(s => s.IsSelected).Select(s => s.Name));
     }   
}

Leave a Comment