title: How to call a C# static method from jQuery
body: <p>I've seen some articles showing how to call a C# method from JavaScript using Microsoft's [WebMethod] for a Web Forms application. I'd like to do the same with an ASP.NET MVC application. I have a C# static method that returns translated data:</p>
  
  <pre><code>public static string Translate(string word)
  {
    return langRepo.Translate(word);
  }
  </code></pre>
  
  <p>The above function works fine inside server-side code. However, I'd like to extend the same code to the client side. Ideally I would like to create a jQuery function like this:</p>
  
  <pre><code>function Translate(word) {
    //call C# translate method and return result
  }
  </code></pre>
  
  <p>And use it like this:</p>
  
  <pre><code>"&lt;hr /&gt;&lt;h5&gt;" + Translate(heading) + "&lt;/h5&gt;";
  </code></pre>
  
  <p>How would I do this?</p>
  
  <p><a href="https://i.stack.imgur.com/xXtk7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xXtk7.png" alt="Enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/d4CCN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/d4CCN.png" alt="Enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/FPTf1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FPTf1.png" alt="Enter image description here"></a></p>