There is no way to use multiple model in the view. But definitely there is a way you can achieve the result using following methond:
1. create class which will return the combined data
public class StudentCourses
{
public Student Student { get; set; }
public Course Course { get; set; }
}
public class Student
{
public string FirstName { get; set; }
public string LastName { get; set; }
}
public class Course
{
public int CourseId { get; set; }
public string Grade { get; set; }
public string Title { get; set; }
}
2. Return combine data model to View
Student st = new Student
{
FirstName = model.FirstName,
LastName = model.LastName,
};
Course crse = new Course
{
CourseId = model.CourseId,
Grade = model.Grade,
Title = model.Title,
};
var StudentCourses = new StudentCourses() { Student = st; Course = crse};
return RedirectToAction("Results", "StudentResults", StudentCourses);
3. Use model in View
@using StudentCourses;
4. Usage to show data in HTML page
Student Information
@Model.Student.FirstName
Course Information
@Model.Course.Title
Regards,
Imdadhusen