views:

23

answers:

1
+1  Q: 

Error wrong type?

The model item passed into the dictionary is of type '...', but this dictionary requires a model item of type '...'

Does anyone know how to solve this error?

My controller class:

public class MapsController : Controller
{

    public ActionResult Index()
    {
        return View(Project.Find(68));
     }


    //[AutoRefresh(DurationInSeconds = 30)]

    public ActionResult Map()
    {     
        var map = DeviceLocation.FindAll();
        Locations l = new Locations();
        l.locations = map;
        return Json(l, JsonRequestBehavior.AllowGet);
    }
}

My view

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<App.Models.Project>>" %>
+1  A: 

It sounds like the wrong type is specified in your view.

Your view should start with something like:

<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<...>" %>

The ... above should actually be the same type as that passed into the view from your controller.

RedFilter
I am using a for each loop in my view, the for each wouldnt work if I remove the IEnumerable. I updated my question with the view code.
Prd
It would help if you would show the full error message instead of hiding the types, esp. since types seeem to be the issue. As well, show the rest of your view.
RedFilter