Whenever i m passing data from Controller to View this error is showing
Server Error in '/' Application.
The model item passed into the dictionary is of type 'System.Collections.Generic.List`1[<>f__AnonymousType1`6[System.String,System.String,System.Nullable`1[System.DateTime],System.Nullable`1[System.DateTime],System.String,System.String]]', but this dictionary requires a model item of type 'System.Collections.Generic.IList`1[CaliberCoaching.Models.CareerInformation]'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: The model item passed into the dictionary is of type 'System.Collections.Generic.List`1[<>f__AnonymousType1`6[System.String,System.String,System.Nullable`1[System.DateTime],System.Nullable`1[System.DateTime],System.String,System.String]]', but this dictionary requires a model item of type 'System.Collections.Generic.IList`1[CaliberCoaching.Models.CareerInformation]'.
This is My Controller Code
public ActionResult JobList()
{
CaliberCoachingContext objCaliberCoachingContext = new CaliberCoachingContext();
var lstCareerInformation = (from job in objCaliberCoachingContext.CareerInformations
select new { job.NameOfPost, job.PostName, job.StartDate, job.LastDate, job.Eligibility, job.NoOfVacancies }).ToList();
return View(lstCareerInformation);
}
and here is my view
@model IEnumerable<CaliberCoaching.Models.CareerInformation>
@{
ViewBag.Title = "JobList";
Layout = "~/Views/Shared/_CommonLayout.cshtml";
}
@foreach (var item in Model)
{
<div class="single-item-wrapper">
<div class="courses-content-wrapper">
<h3 class="title-default-left-bold">@item.NameOfPost</h3>
</div>
</div>
}
Please Give me the solution for this Problem.