You could create an action in say, the CommonController
, which returns a partial view containing your navigation. This partial view can have its own model which can be populated from the controller. This allows you to use dependency injection for instance.
The action could look like this:
[ChildActionOnly]
public ActionResult Navigation()
{
var model = new NavigationModel();
// populate the model..
return PartialView("_Navigation", model);
}
You can render this partial in your view (_Layout.cshtml
in your case) like this:
@Html.Action("Navigation", "Common")
For most cases, Request.IsAuthenticated
is just fine. Only use this if you need something more advanced.