Prd
Prd

Reputation: 247

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>>" %>

Upvotes: 1

Views: 185

Answers (1)

D&#39;Arcy Rittich
D&#39;Arcy Rittich

Reputation: 171559

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.

Upvotes: 1

Related Questions