title: WCF Service 405 Method Not Allowed Exception
body: <p>I'm writing a WCF service in Visual Studio 2008 to be hosted on a Windows 2008 Standard server.</p>
  
  <p>I've created a new Web Site in IIS7 with its own application targeted to ASP.NET 2.0. I added .NET 3.0 Framework features to the server role. I've already gone through all of the steps involving *.svc extensions and the aspnet_isapi module. I've run "ServiceModelReg -r" and restarted IIS as well as the server itself.</p>
  
  <p>My project targets the .NET framework 3.5 for builds. My solution references the project as a Web site using a UNC path to the server's Web directory. The project builds without errors and I can successfully add a service reference to my WCF service in my client project (on my Win XP development virtual machine). My client project builds and runs, but throws an exception during the service method (<em>CheckDatabaseConnection</em>) call. My web.config and service classes are attached below, followed by the client app. I've completely run out of ideas!</p>
  
  <p><strong>web.config:</strong></p>
  
  <pre><code>    &lt;system.serviceModel&gt;
      &lt;serviceHostingEnvironment aspNetCompatibilityEnabled="false" /&gt;
      &lt;services&gt;
          &lt;service behaviorConfiguration="ConnectivityBehavior" name="EDCO.Web.Services.Connectivity"&gt;
              &lt;endpoint address="http://validurl.net" binding="wsHttpBinding" contract="EDCO.Web.Services.IConnectivity"&gt;
              &lt;/endpoint&gt;
              &lt;endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/&gt;
          &lt;/service&gt;
      &lt;/services&gt;
      &lt;behaviors&gt;
          &lt;serviceBehaviors&gt;
              &lt;behavior name="ConnectivityBehavior"&gt;
                  &lt;serviceMetadata httpGetEnabled="true"/&gt;
                  &lt;serviceDebug includeExceptionDetailInFaults="false"/&gt;
              &lt;/behavior&gt;
          &lt;/serviceBehaviors&gt;
      &lt;/behaviors&gt;
  &lt;/system.serviceModel&gt;
  </code></pre>
  
  <p><strong>IConnectivity.cs:</strong></p>
  
  <pre><code>    [ServiceContract(Namespace="http://validurl.net")]
  public interface IConnectivity
  {
      #region Methods
  
      [WebGet()]
      [WebInvoke(Method="GET")]
      [OperationContract()]
      bool CheckDatabaseConnection(string server, string database, string user, string password);
  
      #endregion Methods
  } // interface IConnectivity
  </code></pre>
  
  <p><strong>Connectivity.svc.cs:</strong></p>
  
  <pre><code>    public class Connectivity : IConnectivity
  {
      #region Members
  
      const string CONN_STRING = "Server={0};Database={1};User ID={2};Password={3};";
  
      #endregion Members
  
      #region Methods
  
      public bool CheckDatabaseConnection(string server, string database, string user, string password)
      {
          SqlConnection conn = null;
  
          try
          {
              conn = new SqlConnection(string.Format(CONN_STRING, server, database, user, password));
              conn.Open();
          }
          catch
          {
              return false;
          }
          finally
          {
              if (conn != null)
              {
                  if (conn.State != ConnectionState.Closed)
                  {
                      conn.Close();
                  }
                  conn.Dispose();
              }
          }
  
          return true;
      } // CheckDatabaseConnection(server, database, user, password)
  
      #endregion Methods
  } // class Connectivity
  </code></pre>
  
  <p><strong>client Program.cs:</strong></p>
  
  <pre><code>    class Program
  {
      #region Methods
  
      static void Main(string[] args)
      {
  
          Connectivity.ConnectivityClient connect = new Connectivity.ConnectivityClient();
  
          Console.WriteLine("Establishing connection...");
          if (connect.CheckDatabaseConnection("dbServer", "dbName", "login", "password"))
          {
              Console.WriteLine("Successful connection!");
          }
          else
          {
              Console.WriteLine("Connection failed.");
          }
          Console.ReadLine();
      } // Main()
  
      #endregion Methods
  } // class Program
  </code></pre>