title: C# WebMethod - Send and receive same custom object as parameter
body: <p>mycode:</p>
  
  <p>object:</p>
  
  <pre><code>public class Person
  {
  
      private string _Nome;
      private DateTime _Nascimento;
  
      public string Nome { get { return _Nome; } }
      public DateTime Nascimento { get { return _Nascimento; } }
  
      public Person(string Nome, DateTime Nascimento)
      {
          _Nome = Nome;
          _Nascimento = Nascimento;
      }
  
  }
  </code></pre>
  
  <p>page (WebMethods):</p>
  
  <pre><code>[WebMethod]
  public static Person SendPerson()
  {
      return new Person("Jhon Snow", DateTime.Now);
  }
  
  [WebMethod]
  public static string ReceivePerson(Person oPerson)
  {
      return "OK!";
  }
  </code></pre>
  
  <p>javascript:</p>
  
  <pre><code>var Person;
  GetPerson();
  SendPersonBack();
  function GetPerson()
  {
      $.ajax({
          type: "POST",
          url: "frmVenda.aspx/SendPerson",
          data: {},
          contentType: "application/json; charset=utf-8",
          success: function (RequestReturn) {
              Person = RequestReturn.d;
              console.log(Person);
          },
          error: function (error) {
              alert(error.statusText);
          }
      });
  }
  function SendPersonBack()
  {
      $.ajax({
          type: "POST",
          url: "frmVenda.aspx/ReceivePerson",
          data: JSON.stringify({"oPerson": Person}),
          contentType: "application/json; charset=utf-8",
          success: function (RequestReturn) {
              alert(RequestReturn.d);
          },
          error: function (error) {
              alert(error.statusText);
          }
      });
  }
  </code></pre>
  
  <p>I send the object to the clientside normally, but can not receive it back to server.
  Why can not receive it back if the object is the same and their properties as well.
  where is the problem?</p>