title: WCF service returns error method not allowed?
body: <p>I know there are few articles on the internet (including here), but after few hours, still can not find the solution to a problem. I have a service for uploading files to the server. And I am getting http error 405, method not allowed. Tried everything without a success so far. Below is the code of service.</p>
  
  <p><strong>Service contract:</strong></p>
  
  <pre><code>// NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IService1" in both code and config file together.
  [ServiceContract(Name = "ExcelUpload.IUploadFile")]
  public interface IUploadFile
  {
      [OperationContract]
      [DataContractFormat]
      [WebInvoke(Method = "POST",
                 UriTemplate = "Upload/",
                 BodyStyle = WebMessageBodyStyle.Bare,
                 ResponseFormat = WebMessageFormat.Json)]
      ReturnValue FileUpload(Stream File);
      // TODO: Add your service operations here
  }
  
  
  // Use a data contract as illustrated in the sample below to add composite types to service operations.
  [DataContract]
  public class ReturnValue
  {
      [DataMember]
      public bool IsSuccessfull { get; set; }
  }
  </code></pre>
  
  <p><strong>Service class:</strong></p>
  
  <pre><code>// NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in code, svc and config file together.
  // NOTE: In order to launch WCF Test Client for testing this service, please select Service1.svc or Service1.svc.cs at the Solution Explorer and start debugging.
  [ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple,
               InstanceContextMode = InstanceContextMode.PerCall,
               IgnoreExtensionDataObject = true,
               IncludeExceptionDetailInFaults = true)]
  public class UploadFile : IUploadFile
  {
      public ReturnValue FileUpload(Stream File)
      {
          using(FileStream writer = new FileStream(@"C:\temp", FileMode.Create))
          {
              int ReadCount = 0;
              var buffer = new byte[8192];
              while ((ReadCount = File.Read(buffer, 0, buffer.Length)) != 0)
              {
                  writer.Write(buffer, 0, ReadCount);
              }
          }
  
          return new ReturnValue() { IsSuccessfull = true };
      }
  }
  </code></pre>
  
  <p><strong>Web config</strong></p>
  
  <pre><code>&lt;configuration&gt;
    &lt;appSettings&gt;
      &lt;add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" /&gt;
    &lt;/appSettings&gt;
    &lt;system.web&gt;
      &lt;compilation debug="true" targetFramework="4.5" /&gt;
      &lt;httpRuntime targetFramework="4.5"/&gt;
    &lt;/system.web&gt;
    &lt;system.serviceModel&gt;
      &lt;serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"&gt;
        &lt;serviceActivations&gt;
          &lt;add relativeAddress="~/UploadFile.svc" service="ExcelUpload.UploadFile"/&gt;
        &lt;/serviceActivations&gt;
      &lt;/serviceHostingEnvironment&gt;
      &lt;bindings&gt;
        &lt;webHttpBinding&gt;
          &lt;binding name="crossDomain"
                   maxBufferSize="2147483647"
                   maxBufferPoolSize="2147483647"
                   maxReceivedMessageSize="2147483647"
                   transferMode="Streamed"
                   sendTimeout="00:05:00" 
                   crossDomainScriptAccessEnabled="true"&gt;
            &lt;readerQuotas  maxDepth="2147483647"
                           maxStringContentLength="2147483647"
                           maxArrayLength="2147483647"
                           maxBytesPerRead="2147483647"
                           maxNameTableCharCount="2147483647"/&gt;
            &lt;security mode="None" /&gt;
          &lt;/binding&gt;
        &lt;/webHttpBinding&gt;
      &lt;/bindings&gt;
      &lt;behaviors&gt;
        &lt;serviceBehaviors&gt;
          &lt;behavior name="defaultServiceBehaviour"&gt;
            &lt;!-- To avoid disclosing metadata information, set the values below to false before deployment --&gt;
            &lt;serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/&gt;
            &lt;!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information --&gt;
            &lt;serviceDebug includeExceptionDetailInFaults="true"/&gt;s
            &lt;serviceThrottling maxConcurrentCalls="100" maxConcurrentInstances="100" maxConcurrentSessions="100"/&gt;
          &lt;/behavior&gt;
        &lt;/serviceBehaviors&gt;
  
        &lt;endpointBehaviors&gt;
          &lt;behavior name="defaultEndpointBehaviour"&gt;
            &lt;webHttp/&gt;
          &lt;/behavior&gt;
        &lt;/endpointBehaviors&gt;
      &lt;/behaviors&gt;
      &lt;services&gt;
        &lt;service name="ExcelUpload.UploadFile"  behaviorConfiguration="defaultServiceBehaviour"&gt;
          &lt;endpoint address="" behaviorConfiguration="defaultEndpointBehaviour" bindingConfiguration="crossDomain" binding="webHttpBinding" contract="ExcelUpload.IUploadFile"&gt;&lt;/endpoint&gt;
        &lt;/service&gt;
      &lt;/services&gt;
      &lt;protocolMapping&gt;
          &lt;add binding="basicHttpsBinding" scheme="https" /&gt;
      &lt;/protocolMapping&gt;    
    &lt;/system.serviceModel&gt;
    &lt;system.webServer&gt;
      &lt;modules runAllManagedModulesForAllRequests="true"/&gt;
      &lt;!--
          To browse web app root directory during debugging, set the value below to true.
          Set to false before deployment to avoid disclosing web app folder information.
        --&gt;
      &lt;directoryBrowse enabled="true"/&gt;
    &lt;/system.webServer&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p><strong>Corrections to web.config</strong></p>
  
  <pre><code>&lt;security&gt;
    &lt;requestFiltering allowHighBitCharacters="true"&gt;
      &lt;verbs allowUnlisted="false"&gt;
        &lt;add verb="POST" allowed="true"/&gt;
        &lt;add verb="GET" allowed="true"/&gt;
      &lt;/verbs&gt;
    &lt;/requestFiltering&gt;
  &lt;/security&gt;
  </code></pre>