title: Ajax call Web Service in asp.net
body: <p>Failed to load resource: the server responded with a status of 500 (Internal Server Error) localhost:45562/WebService1.asmx/btn  </p>
  
  <p>WebService not load via ajax call, if I write same code in WebForm.aspx.cs everything work nice</p>
  
  <p><strong>WebForm1.aspx</strong></p>
  
  <pre><code>$(document).ready(function () {
  
          $("#btn").click(function () {
              sendAjaxRequest();
          });
  
  
  
          function sendAjaxRequest() {
              $.ajax({
                  async: true,
                  url: "WebService1.asmx/btn",
                  type: "POST",
                  data: "{ surname: 'Axakalov', name: 'Sunnatilla' }",
                  dataType: "json",
                  contentType: "application/json; charset=utf-8",
                  success: responseOut,
                  error: function (error) {
                      debugger;
                      alert(error);
                  }
              });
          };
  
  
          function responseOut(response) {
              $("#out").html(response.d);
          }
  
      });
  </code></pre>
  
  <p><strong>WebService1.asmx</strong> </p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  using System.Web.Services;
  
  namespace WebApplication9
  {
  /// &lt;summary&gt;
  /// Summary description for WebService1
  /// &lt;/summary&gt;
  [WebService(Namespace = "http://tempuri.org/")]
  [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
  [System.ComponentModel.ToolboxItem(false)]
  // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
  // [System.Web.Script.Services.ScriptService]
  public class WebService1 : System.Web.Services.WebService
  {
  
      [WebMethod]
      public string HelloWorld()
      {
          return "Hello World";
      }
  
  
      [WebMethod]
      public string btn(string surname, string name)
      {
          return surname + " " + name;
      }
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Please help, why webservcise1.asmx was not found</p>