title: How to get POST data inside a C# WebMethod?
body: <p>I need to use a jQuery ajax request to post values for processing in C# code behind. I can send data but I don't know how to retrieve it from inside the C# WebMethod.</p>
  
  <pre><code>var cliente;
  $.post(
      "../Dados/GetDados.aspx/GetClienteById",
      {
          Id: id
      },
      function(dado) {
          cliente = dado;
      });
  </code></pre>
  
  <p>And the C# code:</p>
  
  <pre><code>[WebMethod]
  [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
  public static string GetClienteById()
  {
      int PostId = What_can_I_put_here?;
  
      string dados = "null";
  
      using (SysContext db = new SysContext())  // I'm using Entity Framework
      {
          if (db.Clientes.Count(r =&gt; r.Id == PostId) &gt; 0)
              dados = new JavaScriptSerializer().Serialize(db.Clientes.Where(r =&gt; r.Id == PostId).ToList());
      }
      return dados;
  }
  </code></pre>