title: WebMethod Ajax Call 404 Not Found
body: <p>I am trying to create a webform that will send an email when submitted. I created a webmethod and am trying to post with ajax. My ajax is 404ing when I submit. Here is my code. I am a beginner when it comes to .net, and am trying to play around a bit.</p>
  
  <pre><code>$(document).ready(function() {
  $('.validate-form').submit(function (e) {
      e.preventDefault();
      var first_name = document.getElementById("first_name").value;
      var last_name = document.getElementById("last_name").value;
  
      var email = document.getElementById("email").value;
      var data = "{'first name': '" + first_name + "', 'last name': '" + last_name + "', 'fromEmail': '" + 
                 email + "'}";
      console.log("data", data)
      $.ajax({
          type: "POST",
          url: "SendMessage.aspx/SendMessages",
          data: data,
          contentType: "application/json; charset=utf-8",
          dataType: "json"
      }).fail(function (xhr, ajaxOptions, thrownError) {
          console.log(xhr.status);
          console.log(thrownError);
      })
  });
  </code></pre>
  
  <pre class="lang-csharp prettyprint-override"><code>public partial class Send : System.Web.UI.Page
  {
      [WebMethod]
      public static void SendMessages(string first_name, string last_name, string email, string comments)
      {
  
          const string SERVER = "zebra.aa.org";
          const string TOEMAIL = "adhsaj@am.org";
          MailAddress from = new MailAddress(email);
          MailAddress to = new MailAddress(TOEMAIL);
          MailMessage message = new MailMessage(from, to);
  
          message.Subject = "Web Site Contact Inquiry from " + first_name + last_name;
          message.Body = "Message from: " + first_name + last_name + " at " +
                         email + "\n\n" + comments;
          message.IsBodyHtml = false;
          SmtpClient client = new SmtpClient(SERVER);
          client.Send(message);
          Console.WriteLine(message);
      }
  }
  </code></pre>