WCF不会在IIS中托管

问题描述:

我已将我的服务创建为WCF服务应用程序。然后我将这个服务发布到名为“TestService”的文件夹中。我试图将它作为一个网站添加到IIS管理器。一切似乎去罚款,直到我去浏览我总是打招呼的服务:WCF不会在IIS中托管

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

我浏览到这个在http://localhost:8734和网站在IIS在端口8734.在web.config具有托管下面太:

<service behaviorConfiguration="TestServiceBehavior" name="TestApp.Service.TestService"> 
<endpoint address="/Authentication" binding="wsHttpBinding" bindingConfiguration="TestServiceBinding" 
     contract="TestApp.Service.IAuthenticationService" /> 

// ... other endpoints 

<host> 
    <baseAddresses> 
    <add baseAddress="http://localhost:8734/Design_Time_Addresses/TestApp.Service/Service1/" /> 
    </baseAddresses> 
</host> 

任何帮助,将不胜感激。

该服务托管,您需要浏览到服务端点,例如http://localhost:8734/MyService.svc。您得到403的原因是因为您试图浏览部署应用程序的目录,而这通常是不允许的。您可以用web.config setting打开目录浏览。

+0

从发布服务创建的svc文件名为TestApp.Service.TestService.svc,如果我尝试导航到http:// localhost:8734:TestApp.Service.TestService.svc我得到HTTP错误404.3 - 未找到 –

+0

您需要使用svc文件相对于根目录的路径。您的web.config中的基址设置可用于更改此设置。 [这个问题](http://*.com/questions/6937853/wcf-service-endpoints-vs-host-base-address)有解决如何正确使用基地址的答案。 –