I've been struggling for a while to find a sensible way of getting the footer. Well... This is where partial views come useful.
There are several ways to solve this problem. I've created a controller:
1 2 3 4 5 6 7 8 9 10 11 |
public class _OtherController : Controller { Models.DBEntities _db = new Models.DBEntities(); [ChildActionOnly] public ActionResult _Footer() { Footer viewModel = new Footer(); return PartialView("_FooterPartial", viewModel); } } |
In the Shared
folder I've added _FooterPartial.cshtml
and in the layout this line:
1 |
@{Html.RenderAction("_Footer", "_Other");} |
It worked so awesome.