传递到字典中的模型项的类型为“...”,但此字典需要类型为“...”的模型项
有谁知道如何解决这个错误?
我的控制器类:
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);
}
}
我的观点
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<App.Models.Project>>" %>
答案 0 :(得分:1)
听起来您的视图中指定了错误的类型。
您的观点应该从以下内容开始:
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<...>" %>
上面的...
实际上应该与从控制器传递到视图中的类型相同。