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 SharavatPosted Oct 10, 2018, 1:54 AM
Thabo HappyPosted Oct 9, 2018, 4:38 AM
Thabo HappyPosted Oct 9, 2018, 4:16 AM
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
Ruchi SharavatPosted Oct 9, 2018, 4:07 AM