title: WCF "Method Not Allowed" in Visual Studio integrated webserver
body: <p>I have two web projects in Visual Studio 2008 SP1, One hosting a WCF service and another that I am using to consume the WCF service. The service in question exposes a webHttpBinding endpoint and take JSON as input and returns JSON.</p>
  
  <p>I have used Jquery ajax to consume the service from the client web app like so:</p>
  
  <pre><code>$(document).ready(function () {
      var data = '{"myobject":{"Business":"PIZZA"}}';
      $.ajax({
          type: "POST",
          contentType: "application/json",
          data: data,
          dataType: 'json',
          url: "http://localhost:1212/JobInfo.svc/ReturnThisString",
          error:
              function(XMLHttpRequest, textStatus, errorThrown) {
                  alert("Error");
              },
          success: function(data) {
              alert("BoolValue: " + data.GetDataUsingDataContractResult.BoolValue);
              alert("StringValue: " + data.GetDataUsingDataContractResult.StringValue);
          }
      });
  
  });
  </code></pre>
  
  <p>And I get the following error in the Firebug HTML request:</p>
  
  <pre><code>http://localhost:1212/JobInfo.svc/ReturnThisString 405 Method Not Allowed
  </code></pre>
  
  <p>But if run the exact same file in the web project that is hosting the project it works fine.</p>
  
  <p>The hosting project is running on set port localhost:1212 and the client on localhost:RANDOM_PORT. As the localhost is the same I would imagine its not a Cross Domain issue? Or does the port part count also?</p>
  
  <p>The server contract is as follows:</p>
  
  <pre><code>[OperationContract]
  [WebInvoke(Method="POST",UriTemplate="ReturnThisString", 
          BodyStyle=WebMessageBodyStyle.Wrapped, 
          RequestFormat=WebMessageFormat.Json, 
          ResponseFormat=WebMessageFormat.Json)]
  EventListArgs ReturnThisString(EventListArgs myobject);
  
  [Serializable]
  [DataContract]
  public class EventListArgs {
  
      [DataMember( IsRequired = false)]
      public string Business;
  
      [DataMember( IsRequired = false)]
      public string Feeder;
  
  }
  </code></pre>
  
  <p>And the implemented code is:</p>
  
  <pre><code>public EventListArgs ReturnThisString(EventListArgs myobject)
  {
      return myobject;
  }
  </code></pre>
  
  <p>This was added as a simple method to prove I had not just done something silly. What I like to call a sanity check. Its a simple function that takes a complex(of type other then string) JSON object as a parameter and returns a complex JSON object.</p>
  
  <p><img src="https://i.stack.imgur.com/7esM6.png" alt="enter image description here"></p>
  
  <p>As you can see above I have two web project that use the Visual Studio Built in web server (local IIS install not possible). The above configuration does not work but if you can see I have also got the Darkside test page in the server host which is an exact copy from the client and this work with no problems at all.</p>