【发布时间】:2019-01-04 10:08:58
【问题描述】:
我在 Visual Studio 中有一个 WCF 服务应用程序项目,其中包含以下文件
- ZooWebService.svc
- 网络配置
我试图在 IIS 中托管 Web 服务,但是当我从 IIS 浏览到我的 Web 服务时,Web 服务根本没有加载。它只是在浏览器中显示“正在加载”。
这是我的 WebConfig 文件:
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="false" targetFramework="4.6.1" />
<httpRuntime targetFramework="4.6.1"/>
</system.web>
<system.serviceModel>
<services>
<service behaviorConfiguration="Default"
name="WCFWebService.ZooWCFService">
<endpoint address="" binding="basicHttpBinding"
contract="WCFWebService.IZooWCFService" />
<endpoint address="mex" binding="mexHttpBinding"
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8080/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="webBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="Default">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
我做了以下,我做错了什么?
- 打开 IIS
- 右键单击默认网站
- 已选择“添加应用程序”
- 填充的“别名”字段
- 将“物理路径”填充到解决方案内容所在的目录
- 点击确定
- 在 Visual Studio 中重建解决方案
【问题讨论】:
-
在 IIS 中,您的身份验证设置为什么?您是否在 IIS 中为端口 8080 设置了绑定,并且在您的项目中的属性 -> Web 是否指向localhost:8080?
-
我会检查这个。我正在使用的 IIS 是运行 Windows 10 的本地计算机上的 IIS 10。这有关系吗?