这是我第一次使用WCF Web服务和IIS。我托管我的WCF Web服务的方式是通过.svc文件。我在我的IIS中添加了一个网站,并将其指向包含.svc文件的文件夹。
现在,在配置IIS时,它确实要求我输入主机名,我输入localhost 假设这将是我网站的地址。
但事实并非如此。我正在浏览localhost并获得404.现在,当我运行具有WCF服务网站项目的服务(包含.svc文件的项目)时,它确实填充了WCF客户端窗口,该窗口显示以下地址作为我的服务地址:
http://localhost:31893/Employee.svc。我正在添加我的web.config文件,仅供参考。
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true"/>
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5"/>
<httpRuntime targetFramework="4.5"/>
</system.web>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="EmployeeServiceBinding" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="16384" maxNameTableCharCount="16384"/>
<security mode="None">
<transport clientCredentialType="None"/>
<message clientCredentialType="None" negotiateServiceCredential="false" establishSecurityContext="false"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service name="PL.HR.Employees.WebService.HREmployeeWebService">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="EmployeeServiceBinding" name="StandardEndpoint" contract="PL.HR.Employees.WebService.IHREmployeeWebService"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="false"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="false" multipleSiteBindingsEnabled="false"/>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<!--
To browse web app root directory during debugging, set the value below to true.
Set to false before deployment to avoid disclosing web app folder information.
-->
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>
现在,我认为这必须是VS在运行时生成的Visual Studion Dev环境地址。但是这不是我添加到IIS中的WebHost的地址。这提出了几个问题:
答案 0 :(得分:0)
localhost末尾的那个数字是IIS正在侦听的端口号。如果您需要域,可以在%windir%\ system32 \ drivers \ etc \ hosts
编辑主机文件127.0.0.1 domain.com
Web.config保存IIS中的设置。因此,如果您在IIS中更改某些内容,则会修改Web.config(反之亦然),这会导致AppPool的回收。
编辑站点的绑定将允许您设置特定的端口号,但您必须更改VS中的调试选项,以便它知道托管正在调试的代码的内容。
原谅我没有格式化,我在午休时间使用堆栈交换应用程序。