title: Web (ASP.Net) Wcf: Not Found Error connecting from desktop client
body: <p>I am setting up an ASP.Net WebForms sub-domain with WCF hosted on a shared hosting account. WCF is the primary purpose of the site at the moment. I am having trouble establishing a link from my desktop yielding a perpetual</p>
  
  <blockquote>
    <p>Unable to connect to the remote server</p>
  </blockquote>
  
  <p>I am trying from both <code>Add Service Reference</code> and from C#. I want C# code at the end on the client.</p>
  
  <p>I keep playing around with port numbers and different types of bindings, but nothing works.</p>
  
  <p><strong>Web.config</strong>:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;configuration&gt;
    &lt;system.web&gt;
      &lt;compilation debug="true" targetFramework="4.6.2"/&gt;
      &lt;httpRuntime targetFramework="4.5"/&gt;
    &lt;/system.web&gt;
    &lt;system.codedom&gt;
      &lt;compilers&gt;
        &lt;compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701"/&gt;
        &lt;compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\&amp;quot;Web\&amp;quot; /optionInfer+"/&gt;
      &lt;/compilers&gt;
    &lt;/system.codedom&gt;
      &lt;system.serviceModel&gt;
          &lt;services&gt;
              &lt;service name="MyCloud.Communication.CloudService" behaviorConfiguration="BehaviorMyCloudService"&gt;
                  &lt;endpoint address=""
                                      binding="wsHttpBinding"
                                      bindingConfiguration="EndpointBindingMyCloudService"
                                      contract="MyCloud.Communication.ICloudService"
                                      behaviorConfiguration="web"
                                      &gt;
                  &lt;/endpoint&gt;
                  &lt;endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /&gt;
                  &lt;host&gt;
                      &lt;baseAddresses&gt;
                          &lt;add baseAddress="http://localhost/MyCloudService/"/&gt;
                      &lt;/baseAddresses&gt;
                  &lt;/host&gt;
              &lt;/service&gt;
          &lt;/services&gt;
          &lt;behaviors&gt;
              &lt;serviceBehaviors&gt;
                  &lt;behavior name="BehaviorMyCloudService"&gt;
                      &lt;serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" /&gt;
                      &lt;serviceDebug includeExceptionDetailInFaults="true" /&gt;
                      &lt;dataContractSerializer maxItemsInObjectGraph="2147483647" /&gt;
                      &lt;useRequestHeadersForMetadataAddress&gt;
                          &lt;defaultPorts&gt;
                              &lt;add scheme="http" port="8080" /&gt;
                          &lt;/defaultPorts&gt;
                      &lt;/useRequestHeadersForMetadataAddress&gt;
                  &lt;/behavior&gt;
                  &lt;behavior name=""&gt;
                      &lt;serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" /&gt;
                      &lt;serviceDebug includeExceptionDetailInFaults="false" /&gt;
                  &lt;/behavior&gt;
              &lt;/serviceBehaviors&gt;
              &lt;endpointBehaviors&gt;
                  &lt;behavior name="web"&gt;
                      &lt;webHttp /&gt;
                  &lt;/behavior&gt;
              &lt;/endpointBehaviors&gt;
          &lt;/behaviors&gt;
          &lt;bindings&gt;
              &lt;wsHttpBinding&gt;
                  &lt;binding
                      name="EndpointBindingMyCloudService"
                      allowCookies="false"
                      closeTimeout="00:01:00"
                      openTimeout="00:01:00"
                      receiveTimeout="00:10:00"
                      sendTimeout="00:01:00"
                      maxBufferPoolSize="524288"
                      maxReceivedMessageSize="2147483647"
                      messageEncoding="Text"
                      textEncoding="utf-8"
                      transactionFlow="false"
                      useDefaultWebProxy="true"
                      &gt;
                      &lt;security mode="None"&gt;
                      &lt;/security&gt;
                  &lt;/binding&gt;
              &lt;/wsHttpBinding&gt;
          &lt;/bindings&gt;
          &lt;serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"&gt;
              &lt;baseAddressPrefixFilters&gt;
                  &lt;add prefix="http://localhost:8080"/&gt;
              &lt;/baseAddressPrefixFilters&gt;
          &lt;/serviceHostingEnvironment&gt;
      &lt;/system.serviceModel&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p><strong>CloudService.svc (C# Code)</strong>:</p>
  
  <pre><code>using System;
  using System.IO;
  using System.ServiceModel;
  using System.ServiceModel.Channels;
  using System.ServiceModel.Dispatcher;
  using System.Web;
  
  namespace MyCloud.Communication
  {
      [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]
      public class CloudService : ICloudService, IErrorHandler
      {
          public UInt16 GetServiceId()
          {
              return MyCloudLibrary.Constants.My_Id_CloudService;
          }
      }
  }
  </code></pre>
  
  <p><strong>ICloudService.cs</strong>:</p>
  
  <pre><code>using System;
  using System.IO;
  using System.ServiceModel;
  using System.ServiceModel.Web;
  
  namespace MyCloud.Communication
  {
      [ServiceContract(SessionMode = SessionMode.Allowed/*, CallbackContract = typeof(ICallbackCloudService)*/)]
      public interface ICloudService
      {
          [OperationContract(IsOneWay = false)]
          [FaultContractAttribute(typeof(CloudServiceFault))]
          UInt16 GetServiceId();
      }
  }
  </code></pre>
  
  <p><strong>Client Side C# Code</strong>:</p>
  
  <pre><code>WSHttpBinding binding = new WSHttpBinding();
  binding.Security.Mode = SecurityMode.None;
  EndpointAddress endpointAddress = new EndpointAddress("http://Mycloud.asdfmydomain.com/MyCloudService");
  var pipeFactory = new ChannelFactory&lt;ICloudService&gt;(binding, endpointAddress);
  Program.HostIpcCloudService = pipeFactory.CreateChannel();
  Program.HostIpcCloudService.Connect();
  CommCloudService.IsPipeCloudService = true;
  UInt16 serviceId = Program.HostIpcCloudService.GetServiceId();
  </code></pre>
  
  <p><strong>Client Side C# Error</strong>:</p>
  
  <blockquote>
    <p>OuterException:</p>
    
    <p>"There was no endpoint listening at
    <a href="http://mycloud.asdfmydomain.com/MyCloudService" rel="nofollow noreferrer">http://mycloud.asdfmydomain.com/MyCloudService</a> that could accept the
    message. This is often caused by an incorrect address or SOAP action.
    See InnerException, if present, for more details."</p>
    
    <p>InnerException:</p>
    
    <p>"The remote server returned an error: (404) Not Found."</p>
  </blockquote>
  
  <p>The <code>Add Service Reference</code> from <code>Visual Studio 2017</code> said the same thing.</p>
  
  <p>I got similar code working from my Windows Service, so maybe the problem is that I am going cross machine, possibly ports, possibly a firewall on the hosting account, etc.</p>
  
  <p>Some (but not all) references:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/8765798/wcf-web-config-file">wcf web.config file</a></li>
  <li><a href="https://stackoverflow.com/questions/5070468/wcf-web-config-question">WCF Web.Config Question</a></li>
  <li><a href="https://stackoverflow.com/questions/2943148/how-to-programmatically-connect-a-client-to-a-wcf-service">how to programmatically connect a client to a wcf service</a></li>
  <li><a href="https://docs.microsoft.com/en-us/dotnet/framework/wcf/wcf-client-overview" rel="nofollow noreferrer">MS: wcf client overview</a></li>
  <li>etc., etc.</li>
  </ul>
  
  <p>Thoughts?</p>
  
  <p><strong>UPDATE BASED ON ANSWER 1:</strong></p>
  
  <p>(SO should pay me a pain and suffering fee for having to endure this hugely annoying celebration April Fool's theme. I am attempting to focus on programming and stay focused.)</p>
  
  <p>I am making progress, no dice yet.</p>
  
  <p>My no service found error message and duplicated <code>MyCloud.Communication.MyCloud</code> rather than <code>MyCLoud.Communication.CloudService</code> error message was the result of an incomplete refactoring on the part of Visual Studio. Visual Studio did NOT refactor the .SVC markup file.</p>
  
  <pre><code>&lt;%@ ServiceHost Language="C#" Debug="true" Service="MyCloud.Communication.CloudService" CodeBehind="CloudService.svc.cs" %&gt;
  </code></pre>
  
  <p>Specifying in a browser the following URL yields:</p>
  
  <pre><code>http://mycloud.asdfmydomain.com/Communication/CloudService.svc/Address1
  </code></pre>
  
  <p>Here is a key part of the URL from the Microsoft <a href="https://docs.microsoft.com/en-us/dotnet/framework/wcf/specifying-an-endpoint-address" rel="nofollow noreferrer">link</a>:</p>
  
  <blockquote>
    <p>or you can provide a base address for the ServiceHost of a service and then specify an address for each endpoint associated with this service that is defined relative to this base address.
    Path: /mathservice.svc/secureEndpoint</p>
  </blockquote>
  
  <p>I had to remove the commented out <code>&lt;serviceHostingEnvironment</code> because the browser wanted <code>multipleSiteBindingsEnabled="true"</code>.</p>
  
  <p>The text says that the first part of the URI is the <code>path to the SVC file</code> followed by the <code>endpoint address name</code> specified in the <code>EndPointAddres</code> tag.</p>
  
  <p><strong>Error Via Chrome:</strong></p>
  
  <pre><code>[ServiceActivationException: The service '/Communication/CloudService.svc' cannot be activated due to an exception during compilation.  The exception message is: The endpoint at 'http://mycloud.asdfmydomain.com/Communication/CloudService.svc/Address1' does not have a Binding with the None MessageVersion.  'System.ServiceModel.Description.WebHttpBehavior' is only intended for use with WebHttpBinding or similar bindings..]
  </code></pre>
  
  <p><strong>Error Via C#:</strong></p>
  
  <pre><code>{"The requested service, 'http://mycloud.asdfmydomain.com/Communication/CloudService.svc/Address1' could not be activated. See the server's diagnostic trace logs for more information."}
  </code></pre>
  
  <p>I am making progress.</p>