Search code examples
c#asp.netweb-serviceswcfiis-7

I am getting error 404 on run WCF services. web-services don't work on live Server


I have a WCF service created with VS2013 on Win8. If I start the service via VS (localhost:port) I'm able to do GET response in json

but same service i am hosted on server (IIS7) then i get 404 Error

localhost URL : http://localhost:43596/abc.svc/LoginUser/abc/abc

Live URL: http://mywwebsite.com:80/abc.svc/LoginUser/abc/abc


Solution

  • In my opionio, there might something amiss with the hosting environment, try to enable WCF feature support in IIS.
    enter image description here
    enter image description here
    Here is my service, wish it is useful to you.
    IService1.cs

    [ServiceContract]
    public interface IService1
    {
    
        [OperationContract]
        [WebGet]
        string GetData(int value);
    

    Service1.svc.

    public class Service1 : IService1
    {
        public string GetData(int value)
        {
            return string.Format("You entered: {0}", value);
        }
    

    Web.config

      <system.serviceModel>
        <behaviors>
          <serviceBehaviors>
            <behavior>
              <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
              <serviceDebug includeExceptionDetailInFaults="false" />
            </behavior>
          </serviceBehaviors>
          <endpointBehaviors>
            <behavior>
              <webHttp />
            </behavior>
          </endpointBehaviors>
        </behaviors>
        <bindings>
          <webHttpBinding>
            <binding name="mybinding">
              <security mode="Transport">
                <transport clientCredentialType="None"></transport>
              </security>
            </binding>
          </webHttpBinding>
        </bindings>
        <protocolMapping>
          <add binding="webHttpBinding" scheme="http"/>
          <add binding="webHttpBinding" scheme="https" bindingConfiguration="mybinding"/>
        </protocolMapping>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
      </system.serviceModel>
    

    Since the above configuration support both http and https protocol, we need to add http and https binding in IIS site binding module.
    enter image description here
    enter image description here
    Reference.
    How to make WCF Service Use HTTPS protocol
    Feel free to let me know if there is anything I can help with.