title: The remote server returned an unexpected response: (405) Method Not Allowed
body: <p>I have the following code:</p>
  
  <p>which return me the following exception:</p>
  
  <pre><code>ProtocolException was unhandled by user code
  
  The remote server returned an unexpected response: (405) Method Not Allowed.
  </code></pre>
  
  <p>I tried using the following command (Using <code>Administrator</code> in a Command Prompt):</p>
  
  <pre><code>C:\Windows\Microsoft.NET\Framework\v3.0\Windows Communication Foundation&gt;ServiceModelReg.exe -i
  </code></pre>
  
  <p>and the following appear:</p>
  
  <pre><code>Microsoft(R) Windows Communication Foundation Installation Utility
  [Microsoft (R) Windows (R) Communication Foundation, Version 3.0.4506.5420]
  Copyright (c) Microsoft Corporation.  All rights reserved.
  
  
  Installing: Machine.config Section Groups and Handlers (WOW64)
  
  Installing: Machine.config Section Groups and Handlers
  
  Installing: System.Web Build Provider (WOW64)
  
  Installing: System.Web Compilation Assemblies (WOW64)
  
  Installing: HTTP Handlers (WOW64)
  
  Installing: HTTP Modules (WOW64)
  
  Installing: System.Web Build Provider
  
  Installing: System.Web Compilation Assemblies
  
  Installing: HTTP Handlers
  
  Installing: HTTP Modules
  
  Installing: Protocol node for protocol net.tcp (WOW64)
  
  Installing: TransportConfiguration node for protocol net.tcp (WOW64)
  
  Installing: ListenerAdapter node for protocol net.tcp
  
  Installing: Protocol node for protocol net.tcp
  
  Installing: TransportConfiguration node for protocol net.tcp
  
  Installing: Protocol node for protocol net.pipe (WOW64)
  
  Installing: TransportConfiguration node for protocol net.pipe (WOW64)
  
  Installing: ListenerAdapter node for protocol net.pipe
  
  Installing: Protocol node for protocol net.pipe
  
  Installing: TransportConfiguration node for protocol net.pipe
  
  Installing: Protocol node for protocol net.msmq (WOW64)
  
  Installing: TransportConfiguration node for protocol net.msmq (WOW64)
  
  Installing: ListenerAdapter node for protocol net.msmq
  
  Installing: Protocol node for protocol net.msmq
  
  Installing: TransportConfiguration node for protocol net.msmq
  
  Installing: Protocol node for protocol msmq.formatname (WOW64)
  
  Installing: TransportConfiguration node for protocol msmq.formatname (WOW64)
  
  Installing: ListenerAdapter node for protocol msmq.formatname
  
  Installing: Protocol node for protocol msmq.formatname
  
  Installing: TransportConfiguration node for protocol msmq.formatname
  
  Installing: HTTP Modules (WAS)
  
  Installing: HTTP Handlers (WAS)
  </code></pre>
  
  <p>However, the exception is still there!</p>
  
  <p>Appreciate any advices.</p>
  
  <p>(Could it be due to .NET Framework?)</p>
  
  <p>I tried the following:</p>
  
  <pre><code>C:\Windows\Microsoft.NET\Framework\v4.0.30319&gt;ServiceModelReg.exe -i
  </code></pre>
  
  <p>but it return me the following:</p>
  
  <pre><code>[Error]Switch '-c' requires a component to be specified for installation or uninstallation. Please specify which components to install or uninstall.
  </code></pre>
  
  <p>Appreciate any helpful advices.</p>
  
  <p><strong>Added Information</strong></p>
  
  <p><strong>Customers.aspx.cs</strong></p>
  
  <pre><code>public partial class Services_Customers : System.Web.UI.Page
  {
  
      private System.Data.DataTable countryDataTable = null;
  
      protected void Page_Load(object sender, EventArgs e)
      {
          // Retrieve DataTable from cache
          countryDataTable =
          (System.Data.DataTable)Cache["Countries"];
  
      }
      protected void GetCountriesButton_Click(object sender, EventArgs e)
      {
  
          // Does cached item exist?
          if (countryDataTable == null)
          {
  
              CustomersClient customersService = new CustomersClient();
              // Retrieve DataTable from WCF Service
              countryDataTable = customersService.GetCountries(StartingLettersTextBox.Text);
  
              // Save DataTable to cache
              Cache["Countries"] = countryDataTable;
  
          }
  
          // Set GridView DataSource
          CustomersGridView.DataSource = countryDataTable;
          CustomersGridView.DataBind();
      }
  }
  </code></pre>
  
  <p><strong>web.config</strong></p>
  
  <p>The following code is inside the <code>&lt;configuration&gt;</code> in the web.config file:</p>
  
  <pre><code>&lt;system.serviceModel&gt;
  &lt;bindings&gt;
    &lt;basicHttpBinding&gt;
      &lt;binding name="BasicHttpBinding_ICustomers" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true"&gt;
        &lt;readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" /&gt;
        &lt;security mode="None"&gt;
          &lt;transport clientCredentialType="None" proxyCredentialType="None" realm="" /&gt;
          &lt;message clientCredentialType="UserName" algorithmSuite="Default" /&gt;
        &lt;/security&gt;
      &lt;/binding&gt;
    &lt;/basicHttpBinding&gt;
  &lt;/bindings&gt;
  &lt;client&gt;
    &lt;endpoint address="http://localhost:1112/Services/Customers.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ICustomers" contract="CustomersService.ICustomers" name="BasicHttpBinding_ICustomers" /&gt;
  &lt;/client&gt;
  &lt;serviceHostingEnvironment aspNetCompatibilityEnabled="true" /&gt;
  &lt;/system.serviceModel&gt;
  </code></pre>