title: 405 method not allowed using [webHttpBinding]
body: <p>I'm getting problems with jquery call wcf. I've already search and found some solutions but it still raise me an error "405 method not allowed". Below is may code</p>
  
  <p>-Interface </p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Runtime.Serialization;
  using System.Text;
  using System.ServiceModel.Activation;
  using System.ServiceModel.Web;
  using System.ServiceModel;
  
  namespace WcfServiceLibrary
  {
      // NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IContactService" in both code and config file together.
      [ServiceContract]
      public interface IContactService
      {
          [WebInvoke(Method = "GET",
           ResponseFormat = WebMessageFormat.Json)]
          [OperationContract]
          Contact GetContactInfo();
      }
  }
  </code></pre>
  
  <ul>
  <li><p>My service</p>
  
  <p>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Runtime.Serialization;
  using System.ServiceModel;
  using System.Text;
  using System.ServiceModel.Activation;
  using System.ServiceModel.Web;
  using System.ServiceModel;</p>
  
  <p>namespace WcfServiceLibrary
  {
      // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "ContactService" in both code and config file together.</p>
  
  <pre><code>[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
  public class ContactService : IContactService
  {
  
      public Contact GetContactInfo()
      {
          ContactBL contactBL = new ContactBL();
  
          return contactBL.GetContact();
      }
  
  }
  </code></pre>
  
  <p>}</p></li>
  <li><p>My object</p></li>
  </ul>
  
  <p>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Runtime;
  using System.Runtime.Serialization;</p>
  
  <pre><code>namespace WcfServiceLibrary
  {
      [DataContract]
      public class Contact
      {
          [DataMember]
          public int Id {get;set;}
          [DataMember]
          public string Fullname {get; set;}
          [DataMember]
          public string email { get; set; }
      }
  }
  </code></pre>
  
  <ul>
  <li>BL </li>
  </ul>
  
  <p>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;</p>
  
  <pre><code>namespace WcfServiceLibrary
  {
      class ContactBL
      {
          public ContactBL() { }
          public Contact GetContact()
          {
              return new Contact {email="thang.nguyen@saas.com.vn", Fullname="NVTThang",Id=2 };
          }
      }
  }
  </code></pre>
  
  <p>And also my WCF configuration:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;configuration&gt;
    &lt;system.web&gt;
      &lt;compilation debug="true" targetFramework="4.0"/&gt;
    &lt;/system.web&gt;
    &lt;system.serviceModel&gt;
      &lt;bindings&gt;
        &lt;webHttpBinding&gt;
          &lt;binding name="webBinding"&gt;
            &lt;security mode="None" /&gt;
          &lt;/binding&gt;
        &lt;/webHttpBinding&gt;
      &lt;/bindings&gt;
      &lt;services&gt;
        &lt;service behaviorConfiguration="myBehavior" name="WcfServiceLibrary.ContactService"&gt;
          &lt;endpoint address="ajaxEp" behaviorConfiguration="epAjaxBehavior"
            binding="webHttpBinding" bindingConfiguration="webBinding" name="epWebHttp"
            contract="WcfServiceLibrary.IContactService" /&gt;
          &lt;endpoint address="mex" binding="mexHttpBinding" name="epMex"
            contract="IMetadataExchange" /&gt;
        &lt;/service&gt;
      &lt;/services&gt;
      &lt;behaviors&gt;
        &lt;endpointBehaviors&gt;
          &lt;behavior name="epAjaxBehavior"&gt;
            &lt;webHttp /&gt;
            &lt;enableWebScript/&gt;
          &lt;/behavior&gt;
        &lt;/endpointBehaviors&gt;
        &lt;serviceBehaviors&gt;
          &lt;behavior name="myBehavior"&gt;
            &lt;serviceMetadata httpGetEnabled="true" /&gt;
            &lt;serviceDebug includeExceptionDetailInFaults="true" /&gt;
          &lt;/behavior&gt;
        &lt;/serviceBehaviors&gt;
      &lt;/behaviors&gt;
      &lt;serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"&gt;
        &lt;baseAddressPrefixFilters&gt;
          &lt;add prefix="http://localhost"/&gt;
        &lt;/baseAddressPrefixFilters&gt;
      &lt;/serviceHostingEnvironment&gt;
    &lt;/system.serviceModel&gt;
    &lt;system.webServer&gt;
      &lt;modules runAllManagedModulesForAllRequests="true"/&gt;
    &lt;/system.webServer&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>The I deploy my wcf on IIS 7.5 then I created a web client using jquery ajax call to my service. </p>
  
  <pre><code>$.ajax({
                  type: "GET", 
                  url: "http://localhost/WcfTestService/Service.svc/ajaxEp/GetContactInfo", 
                  data: '',
                  contentType: "application/json;charset=utf-8", 
                  dataType: "json", 
                  processdata: true,
                  success: function (msg) {
                      alert(msg);
                      //ServiceSucceeded(msg);
                  },
                  error: ServiceFailed
              });
  
   function ServiceFailed(err){
              alert(err.responseText);
  
              return;
          }
  </code></pre>
  
  <p>when I call my service it always raises me "405 Method Not Allowed" and I've tried aspnet_regiis -i and ServiceModelReg -i but it didn't effect. Please suggest me any solutions. </p>
  
  <p>Thanks in advance!</p>