So I have a area setup (Admin). In the Admin Area I have a _ViewStart.cshtml file which links to a Shared/_Layout.cshtml file.
What I need is for the layout file to get some data passed to it (like a model). There will be a drop down at the top right of the page which is common accross all pages in the admin area. It wouldn’t be used in any other areas or the root of the application, only in this area.
Is there a way to assign a common controller to a layout or is Partial the way forward with this?
You could use child actions. You could define a model:
then have a controller:
and then a corresponding partial (
~/Areas/Admins/Views/Items/Index.cshtml):Now, inside the layout of your are you could render this action: