title: mvc _layout call function before renderbody() execute
body: <p>I am working with MVC 5.</p>
  
  <p>I need to call a function before every page is loaded.
  I did it in the <code>_Layout.cshtml</code> view:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code> $(function () {
          $('body').on('click', function (e) {
              var valor = GetSession();
              $('#hdnSessionTime').val(valor);
          });
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>I save a value in a hidden field defined in the layout page, and every time the user click on every page, the function called <code>GetSession</code> executes.</p>
  
  <p>The problem is that it execute after  <code>@RenderBody()</code> and I need it before...</p>
  
  <p>Is that possible?</p>