You could use a child action.
Start by writing a controller in which you could use dependency injection as usual and which will contain a child action:
public class CopyrightController: Controller
{
private readonly IClock clock;
public CopyrightController(IClock clock)
{
this.clock = clock;
}
[ChildActionOnly]
public ActionResult Index()
{
// In this example I am directly passing the IClock instance
// to the partial view as model but in a real application
// you might want to use a view model here
return PartialView(this.clock);
}
}
and then you could have a corresponding partial view (~/Views/Copyright/Index.cshtml
):
@model IClock
<div>Copyright ...</div>
and finally in your _Layout call this child action:
<footer>
@Html.Action("Copyright", "Index")
</footer>