简体   繁体   English

如何使用默认基址配置 WCF 服务?

[英]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当我从 Visual Studio 启动我的 WCF 服务时,它会打开一个浏览器窗口,其中包含一个包含以下内容的页面,地址为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?如何让它显示具有完整 svc URL 的页面? I tried to add the below to service in web.config and it does not make any difference.我尝试将以下内容添加到 web.config 中的服务中,但没有任何区别。 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.默认情况下,网站基地址列出的是WCF项目的内容,而不是服务基地址,可以直接消费。 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.在IIS中托管WCF服务,需要单独处理SVC扩展文件。 Thereby .SVC file is included in the service base address.从而.SVC文件包含在服务基地址中。 We should enable the below windows feature,我们应该启用以下窗口功能,
在此处输入图片说明
And access the below address(replace it with the actual svc file name)并访问以下地址(将其替换为实际的 svc 文件名)

http://localhost:65535/Service1.svc http://localhost:65535/Service1.svc

Hosting WCF service in IIS.在 IIS 中托管 WCF 服务。
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/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) 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.如果问题仍然存在,请随时告诉我。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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