Basically, my _Layout.cshtml file is my MasterPage type V开发者_开发技巧iew.
In it I'm designing the common look that will be shared across all Views.
I'm trying to load a left sidebar with a listing of all Categories in my database. For this purpose I've created a ViewModel called SidebarNavigation.cs
In my _Layout.cshtml I'd like to do something like:
<div id="leftnavigationbar">
@Html.Partial("_SideBarMenu", model)
</div>
But it seems that _Layout.cshtml doesn't actually use a Model up top in the page.
Any suggestions?
Just like in the aspx view engine the layout page "receives" the same model as the content page. For additional view data like this you should add it to the ViewData dictionary
精彩评论