Both my home controller and my "StatusController" create a new instance of a DBEntities. The Home Controller returns a _db.VMs ViewData.Model to the _Layout.cshtml view and the Status Controller returns a _db.Jobs ViewDataModel to the _GetForStatus.cshtml view as a partial view. I call the VMs ViewData model to the _Layout view like so:
@foreach (var m in ViewData.Model)
{
<li><a href="#">@m.Name</a></li>
}
This works fine, populating the dropdown list with names of the VMs from the DB. The _GetforStatus. The Home Controller piece for this is written like so:
public ActionResult index()
{
_db = new IntegrationDBEntitires();
ViewData.Model = _db.VMs.ToList();
return View();
}
The StatusController is written like so:
public PartialViewResult _GetforStatus()
{
_db = new OntegrationDBEntities();
ViewData.Model = _db.Jobs.ToList();
return PartialView();
}
The _GetforStatus view is written like so:
@model IntegrationWeb.Models.Job
<div class="progress progress-striped active">
<div class="progress-bar" style="width: @((Model.IS_Progress / Model.IS_Total)*100)%"></div>
</div>
@Html.Action("_GetforStatus", "StatusController")
This is called in the _Layout view like so:\
@Html.Partial("~/Views/_GetforStatus.cshtml")
I am getting an error here. "The model item passed into the dictionary is of type 'System.Collections.Generic.List' 1[IntegrationWeb.models.VM]', but the dictionary requires model item type 'IntegrationWeb.Models.Job'.
It seems as though there is a conflict with pulling two different DBEntities into the Layout view.
How do I return a View and a Partial View to the Index Layout in ASP.NET MVC 4?
Update: I just put the Action in the Home Controller, since I can't figure out why it won't find my Controller "StatusController". Now I am getting a different error using @{Html.RenderAction("_GetforStatus");} "The Model Item passed into the dictionary is type 'System.Collections.Generic.List '1[IntegrationWeb.models.Job]', but this dictionary requires a model item of type 'IntegrationWeb.models.Job'." Anyone know what is going on here?
partialView()
do? This is not a standard method... – Erik Funkenbusch