【问题标题】:WCF Won't Host in IISWCF 不会在 IIS 中托管
【发布时间】:2015-05-14 11:45:13
【问题描述】:

我已将我的服务创建为 WCF 服务应用程序。然后我将该服务发布到名为“TestService”的文件夹中。我正在尝试将其作为站点添加到 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>

任何帮助将不胜感激。

【问题讨论】:

    标签: c# wcf iis


    【解决方案1】:

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

    【讨论】:

    • 通过发布服务创建的 svc 文件名为 TestApp.Service.TestService.svc,如果我尝试导航到 localhost:8734:TestApp.Service.TestService.svc 我收到 HTTP 错误 404.3 - 未找到
    • 您需要使用相对于根目录的 svc 文件的路径。您的 web.config 中的基地址设置可用于更改此设置。 This question 有解决如何正确使用基地址的答案。
    猜你喜欢
    • 1970-01-01
    • 2016-06-06
    • 2013-10-01
    • 2023-03-21
    • 1970-01-01
    • 2011-07-01
    • 1970-01-01
    • 2022-12-13
    • 1970-01-01
    相关资源
    最近更新 更多