I have a layout
page that has variables that need to be filled. Example:
@ModelType KarateAqua.schoolModel
<html>
<body>
@RenderBody()
<div id="footer">
<div class="content">
<div class="bottom_logo">
<a href="/"><span class="inv">@Model.schoolName</span></a>
</div>
</div>
</div>
</body>
</html>
I don't want to populate this in every ActionResult
. Is there a way to pass data to a layout
page once and do it for all instances?
Your Layout Page:
Your HomeController:
Your BaseController
Logic is easy: You create BaseController which includes every global parameters you will use in layout. (Like username or other data based parameters)
You inherit (call)
BaseController
to get all parameters into your current controller.