Hello am getting this error when im trying to run my code to view data
The model item passed into the dictionary is of type 'System.Collections.Generic.List`1[NewKLUE.Models.Tutorial]', but this dictionary requires a model item of type 'NewKLUE.Models.IndexViewModel'.
My controller
- public async Task PHP()
- {
- var tutorials = db.Tutorials.Where(t => t.CoursesName == "PHP");
- return View(await tutorials.ToListAsync());
- }
- [Table("Tutorial")]
- public class Tutorial
- {
- [Key]
- public int TutorialId { get; set; }
- [Required(ErrorMessage = "Course Name is required")]
- [Display(Name = "Course Name")]
- public string CoursesName { get; set; }
- [Display(Name = "Topic")]
- public string Topic { get; set; }
- [Required(ErrorMessage = "Tutorial discription is required")]
- public string Description { get; set; }
- [AllowHtml]
- public string Content { get; set; }
- public DateTime CreatedOn { get; set; }
- [ForeignKey("User")]
- public string UserId { get; set; }
- public virtual ApplicationUser User { get; set; }
- }
- @model IEnumerable
- @using NewKLUE.Models
- @{
- ViewBag.Title = "PHP";
- }
PHP
class
="table">- @Html.DisplayNameFor(model => model.User.FirstName)
- @Html.DisplayNameFor(model => model.CoursesName)
- @Html.DisplayNameFor(model => model.Topic)
- @Html.DisplayNameFor(model => model.Description)
- @Html.DisplayNameFor(model => model.Content)
- @Html.DisplayNameFor(model => model.CreatedOn)
- @foreach (var item in Model) {
- @Html.DisplayFor(modelItem => item.User.FirstName)
- @Html.DisplayFor(modelItem => item.CoursesName)
- @Html.DisplayFor(modelItem => item.Topic)
- @Html.DisplayFor(modelItem => item.Description)
- @Html.DisplayFor(modelItem => item.Content)
- @Html.DisplayFor(modelItem => item.CreatedOn)
- @Html.ActionLink("Details", "Details", new { id=item.TutorialId })
- }
i ll apriciate any help.

Ruchi SharavatRank #1,714 · 885 reputationPosted Oct 9, 2018, 12:07 AM EDT
Thabo Happy66 reputationPosted Oct 9, 2018, 12:16 AM EDT
class
="col-md-offset-5" style="position: fixed">@currentUser.UserName
@currentUser.Email
@currentUser.FirstName
@currentUser.LastName
@currentUser.Country
@currentUser.Region
@currentUser.Gender
@currentUser.UserBio
@currentUser.Id
Thabo Happy66 reputationPosted Oct 9, 2018, 12:38 AM EDT
Ruchi SharavatRank #1,714 · 885 reputationPosted Oct 9, 2018, 9:54 PM EDT
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts