title: Navigation Menu from database
body: <p>I'm new to ASP.NET Core MVC and I'm generating a menu from database. </p>
  
  <p>I managed to make it work but I have a problem: It only works when the action is index, because the database function is in <code>IActionResult Index()</code> method.</p>
  
  <p>How can I fix this problem? My navigation view in in the <code>_layout.chtml</code>. </p>
  
  <p>How can I make to call the function before rendering the layout? Will this have effect on performance, because it will query database every time?</p>