Tech
Forums
Jobs
Books
Events
Videos
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
2
Answers
I want to solve the given error
Harsh Jani
9y
505
1
Reply
Hi!
I am getting the following error. Can anyone help me solve this error? The code is: -
public class CategoryController : Controller
{
//
// GET: /Category/
ProductsDbEntities ctx;
public CategoryController()
{
ctx = new ProductsDbEntities();
}
public ActionResult Index()
{
try
{
var categoryList = ctx.Categories.ToList();
return View(categoryList);
}
catch (Exception ex)
{
throw ex;
}
}
The code for the View is: -
@model MvcSession.Models.CategoryDetails
@{
ViewBag.Title = "SearchProducts";
}
@using (Html.BeginForm())
{
@Html.EditorFor(cat => cat.CategoryId);
<input type="submit" value="Search" class="btn btn-default" />
}
I am getting the following error when I run the application :-
The model item passed into the dictionary is of type 'System.Collections.Generic.List`1[MvcSession.EntityModel.Category]', but this dictionary requires a model item of type 'MvcSession.Models.CategoryDetails'.
Post
Reset
Cancel
Answers (
2
)
Next Recommended Forum
How to improve the Perfomence of asp.net Webapplication?
About Writing Own Blogs