Search code examples
c#wcf

Hosting Web Service in IIS - Not able to access the service


I have a WCF Service Application project in Visual Studio that contains the following files

  • ZooWebService.svc
  • WebConfig

I attempted to host the Web Service in IIS but when i browse to my web service from IIS the Web Service does not load at all. It just says "loading" in the browser.

Here is my WebConfig file:

 <?xml version="1.0"?>
    <configuration>
    <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
     </appSettings>
     <system.web>
    <compilation debug="false" targetFramework="4.6.1" />
    <httpRuntime targetFramework="4.6.1"/>
     </system.web>
      <system.serviceModel>
    <services>
      <service behaviorConfiguration="Default" 
     name="WCFWebService.ZooWCFService">
        <endpoint address="" binding="basicHttpBinding" 
     contract="WCFWebService.IZooWCFService" />
        <endpoint address="mex" binding="mexHttpBinding" 
        contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8080/" />
          </baseAddresses>
        </host>
        </service>
      </services>
       <behaviors>
      <endpointBehaviors>
        <behavior name="webBehavior">
          <webHttp />
        </behavior>
      </endpointBehaviors>
      <serviceBehaviors>
        <behavior name="Default">
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
         </serviceBehaviors>
       </behaviors>
     </system.serviceModel>
     </configuration>

I did the following so what have i done wrong?

  1. Open IIS
  2. Right clicked on Default Website
  3. Selected "Add Application"
  4. Populated "Alias" field
  5. Populated "Physical Path" to directory of where the solution contents are
  6. Clicked OK
  7. Rebuilt the solution in Visual Studio

Solution

  • We don’t need to specify the base address in the configuration file which needs to be set up in the web site binding module.
    https://social.msdn.microsoft.com/Forums/vstudio/en-US/d42fc165-052d-476a-9580-1240b3d0293d/specify-endpoint-in-wcf-webconfig?forum=wcf
    then we should enable the WCF feature in the IIS. enter image description here
    At last we could see the web service description in http://ip:port/xxxx.svc. enter image description here Feel free to let me know if there is anything I can help with.