title: Call razor method from onclick in view
body: <p>I am trying to find a way to execute a method in my layout view only when a link is clicked. Here's my code so far:</p>
  
  <p>The method I want to call (also in the view):</p>
  
  <pre><code>@functions{
      public void Logout()
      {
          Session.Abandon();
          Response.RedirectToRoute(new { controller = "Home", action = "Index"});
      }
  }
  </code></pre>
  
  <p>The link that'll be clicked to call that method:</p>
  
  <pre><code>&lt;a onclick="// Call the method from here" href="#"&gt;Log Out&lt;/a&gt;
  </code></pre>
  
  <p>The question is, how do I go about this?</p>