title: JQuery consuming ASP.Net Web Service webserver - Request format is unrecognized for URL unexpectedly ending in
body: <p>Done a lot of Googling on this but cant seem to find an answer.</p>
  
  <p>When I call my web service from Jquery I am receiving the error </p>
  
  <pre><code>Request format is unrecognized for URL unexpectedly ending in '/AirportSearchGeneric'. 
  </code></pre>
  
  <p>Factors</p>
  
  <ul>
  <li><p>I am currently calling a webservice that is on the same machine but on a different webserver (calling app is port 64004 and receiving app is 1400) - possible cross "domain" issue? Both are local host.</p></li>
  <li><p>Both are using the test web server that is part of visual studio.</p></li>
  <li><p>I have tried adding the 2 protocols to the web.config (add name="HttpGet" add name="HttpPost")</p></li>
  <li><p>The error occures in the Event Viewer on the server.</p></li>
  <li><p>I get the following in Firebug...</p>
  
  <p>OPTIONS AirportSearchGeneric
  <a href="http://localhost:1400/services/airportservice.asmx/AirportSearchGeneric" rel="nofollow">http://localhost:1400/services/airportservice.asmx/AirportSearchGeneric</a></p>
  
  <p>500 Internal Server Error</p>
  
  <p>localhost:1400</p></li>
  </ul>
  
  <p>... not seen OPTIONS before but the request is being accessed with a POST request.</p>
  
  <p>JQuery code...</p>
  
  <pre><code>$.ajax({
                      type: "POST",
                      url: "http://localhost:1400/services/airportservice.asmx/AirportSearchGeneric",
                      data: "{'criteria':'EGBB', 'maxResults':'10'}",
                      contentType: "application/json; charset=utf-8",
                      dataType: "json",
                      success: function (msg) {
                          alert(msg.d);
                      }
                  });
  </code></pre>
  
  <p>Web service code...</p>
  
  <pre><code>[WebService(Namespace = "http://localhost/WebServices")]
      [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
      [ScriptService]
      public class AirportService : WebService
      {
          [WebMethod]
          [ScriptMethod(ResponseFormat=ResponseFormat.Json)]
          public string AirportSearchGeneric(string criteria, int maxResults)
          {
              IAirportService svc = new Airports.AirportService.AirportService();
              List&lt;AirportSearchResult&gt; res = svc.AirportSearchGeneric(criteria, maxResults);
  
              DataContractJsonSerializer serializer = new DataContractJsonSerializer(res.GetType());
              MemoryStream ms = new MemoryStream();
              serializer.WriteObject(ms, res);
              string jsonString = Encoding.Default.GetString(ms.ToArray());
              ms.Close();
              return jsonString;
          }
      }
  </code></pre>
  
  <p>... dont think its a problem in here as when debugging, no code in here gets executed.</p>
  
  <p>Pretty sure I have covered off all of the reasons I have read as to why this occurs so would be greatful for any advice on how I can get this working.</p>
  
  <p>Cheers.</p>
  
  <p>For reference the firebug headers are as follows:</p>
  
  <pre><code>Host    localhost:1400
  User-Agent  Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12 ( .NET CLR 3.5.30729; .NET4.0E)
  Accept  text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
  Accept-Language en-gb,en;q=0.5
  Accept-Encoding gzip,deflate
  Accept-Charset  ISO-8859-1,utf-8;q=0.7,*;q=0.7
  Keep-Alive  115
  Connection  keep-alive
  Origin  http://localhost:64004
  Access-Control-Request-Me...    POST
  </code></pre>
  
  <p>(No response is received in firebug apart from the 500 error, there is no html response at all).</p>