3

I have a wcf application. It has "Service1.svc" file. In the web.config file I specified

http://localhost:2005/EmployeeService.svc

as an endpoint. When clicking browse from Visual Studio there is no problem. But, when I hosted it on IIS server I get a blank page. The interesting thing is, If I remove the address from the web. config this time I can see the service at this address.

http://localhost:2005/EmployeeService.svc

web.config file is as below:

    <?xml version="1.0"?>
<configuration>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior name="EmployeeServiceBehaviour">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <services>
      <service behaviorConfiguration="EmployeeServiceBehaviour" name="EmployeeConfiguration">
        <endpoint address="http://localhost:2005/EmployeeService.svc" binding="basicHttpBinding"
          bindingConfiguration="" contract="IEmployeeConfiguration" />
      </service>
    </services>
  </system.serviceModel>
  <system.web>
    <compilation debug="true"/>
  </system.web>
  <system.webServer>
    <directoryBrowse enabled="true"/>
  </system.webServer>
</configuration>

Could you please explain, why I get a blank page on IIS when I provide the adress.

Omer
  • 8,194
  • 13
  • 74
  • 92

4 Answers4

4

This may happen in HTTP Activation is not installed in Programs and Features in your Windows installation. Check HTTP Activation for both .Net 3.5 and 4.6 to enable opening WCF service via HTTP request to .svc file hosted in IIS.

Maxim V. Pavlov
  • 10,303
  • 17
  • 74
  • 174
2

I think you can remove all text on the address before Service.svc. This might be an issue with different urls.

When you specify the address part, you tell WCF the service is only available on that address. When going through the endpoints, WCF will not find one that matches the given URL and bail out.

When you have multiple endpoints you need the address field. Otherwise you don't.

Read http://msdn.microsoft.com/en-us/library/ms733749(v=vs.110).aspx

And in particular this part:

When hosting with IIS, you do not manage the ServiceHost instance yourself. The base address is always the address specified in the .svc file for the service when hosting in IIS. So you must use relative endpoint addresses for IIS-hosted service endpoints. Supplying a fully-qualified endpoint address can lead to errors in the deployment of the service.

Patrick Hofman
  • 153,850
  • 22
  • 249
  • 325
  • But the main problem is this: If I specify endpoint adress correctly I get blank page. If I dont specify any endpoint adress I can get the service. So what is the problem with the coerrct endpoint adress. Why am I getting blank page? – Omer Jan 06 '14 at 22:32
  • Thanks, this really clarified the issue – Omer Jan 08 '14 at 10:37
  • I have another computer and on this computer even if I provide address I can see my service. But on the other computer I can't see. I really don't understand why. – Omer Jul 20 '14 at 15:56
1

Check if Service attribute in SVC markup equals your implementation class.

Check endpoint contract name. It has to be exactly full name of your interface. Don't add assembly name, it won't work.

Check <serviceMetadata httpGetEnabled="true" />. If false, you get blank page too.

And 4th change which helped me (but I have no idea why): Remove behavior name <behavior name=""> and remove behaviorConfiguration attribute from service element. It becomes default so the behavior will be used anyway.

Jan Zahradník
  • 2,417
  • 2
  • 33
  • 44
0
  1. Be sure you made an Application Pool with active user like this: https://stackoverflow.com/a/19654633/2148387

  2. Be sure you created Web Application where your WCF is hosted

  3. Check if AppPool and WebApp are running

  4. Enable Directory Browse in your Web.config like here: https://stackoverflow.com/a/19630263/2148387

Hawlett
  • 836
  • 16
  • 23