I am passing two list variables in an ActionResult as Below.
public ActionResult Index()
{
List<category> cat = _business.ViewAllcat().ToList();
List<Books> book = _business.ViewAllBooks().ToList();
return View(book);
}
When I run the Code I get the below error
The model item passed into the dictionary is of type
System.Collections.Generic.List1[Durgesh_Bhai.Models.category], but
this dictionary requires a model item of type
System.Collections.Generic.IEnumerable1[Durgesh_Bhai.Models.Books].
When I am using only one List in Actionresult its working fine.
Best Answer
I am also new to mvc but the solution i got was to create a class which will hold all you required objects as data members and pass the object of that class.
I created a class called data and assigned all my objects to the object of this class and sent that object to model.
or you can use view bag