I have a view to which a Model is bind liked this
@model IEnumerable<InstaFood.Core.Kitchen>
This is how I am trying to add the partial view
@Html.Partial("~/Views/Home/helperTemplates/_menu.cshtml")
In my controller I have this
public ActionResult ViewKitchens()
{
IEnumerable<Kitchen> k = Kitchen.GetAll();
return View(k);
}
In my main view I have a partial view which is bind to a different model like this
@model InstaFood.Core.User
<div class="row">
<div class="large-12 columns">
<nav class="top-bar" data-topbar role="navigation">
<ul class="title-area">
<li class="name">
<h1 class="show-for-small-only"><a href>Menu</a></h1>
</li>
<li class="toggle-topbar menu-icon"><a href="#"><span></span></a>
</li>
</ul>
<section class="top-bar-section">
<ul class="left">
<li class="divider"></li>
<li>@Html.ActionLink("Home", "Dashboard", "Home")</li>
<li class="divider"></li>
<li>@Html.ActionLink("View Kitchens", "ViewKitchens", "Home")</li>
<li class="divider"></li>
<li>@Html.ActionLink("View Institutes", "ViewInstitutes", "Home")</li>
</ul>
<ul class="right">
<li class="has-dropdown">
<a href="#">@Model.EmailAddress</a>
<ul class="dropdown">
<li>@Html.ActionLink("Logout", "Logout", "Account")</li>
</ul>
</li>
</ul>
</section>
</nav>
</div>
Now when I run my code I get this exception,
The model item passed into the dictionary is of type 'Microsoft.WindowsAzure.Storage.Core.Util.CommonUtility+<LazyEnumerable>d__0`1[InstaFood.Core.Kitchen]', but this dictionary requires a model item of type 'InstaFood.Core.User'.
Any solution to this issue? As I am very new to asp.net mvc I am not really sure what is causing this error. My best guess is that it is because of different model binding in a single view.
@Html.Partial(...