简体   繁体   中英

How to configure a WCF service with a default base address?

When I launch my WCF service from visual studio, it opens up a browser window with a page that contains the below and the address is http://localhost:65535

HTTP Error 403.14 - Forbidden
The Web server is configured to not list the contents of this directory.

How can I make it display the page with the complete svc URL? I tried to add the below to service in web.config and it does not make any difference. What else needs to be changed?

Thanks for any advice.

<host>
  <baseAddresses>
    <add baseAddress="http://localhost:65535/TestService.svc"/>
  </baseAddresses>
</host>

By default, the base address of the website lists the content of the WCF project instead of the service base address, which can directly be consumed. In order to list it, please configure the section.

<directoryBrowse enabled="true"/>
  </system.webServer>
</configuration>

For hosting WCF service in IIS, It is necessary to handle the SVC extension file separately. Thereby .SVC file is included in the service base address. We should enable the below windows feature,
在此处输入图片说明
And access the below address(replace it with the actual svc file name)

http://localhost:65535/Service1.svc

Hosting WCF service in IIS.
https://docs.microsoft.com/en-us/dotnet/framework/wcf/feature-details/how-to-host-a-wcf-service-in-iis
https://docs.microsoft.com/en-us/previous-versions/dotnet/netframework-3.5/ms752252(v=vs.90)
Feel free to let me know if the problem still exists.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM