IIS托管的wcf返回我空白页 [英] IIS hosted wcf returns me blank page

查看:49
本文介绍了IIS托管的wcf返回我空白页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个wcf应用程序.它具有"Service1.svc"文件.在我指定的web.config文件中

I have a wcf application. It has "Service1.svc" file. In the web.config file I specified

http://localhost:2005/EmployeeService.svc

作为端点.单击从Visual Studio浏览时,没有问题.但是,当我将其托管在IIS服务器上时,会得到一个空白页.有趣的是,如果我从网上删除地址.这次配置,我可以在该地址看到服务.

as an endpoint. When clicking browse from Visual Studio there is no problem. But, when I hosted it on IIS server I get a blank page. The interesting thing is, If I remove the address from the web. config this time I can see the service at this address.

http://localhost:2005/EmployeeService.svc

web.config文件如下:

web.config file is as below:

    <?xml version="1.0"?>
<configuration>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior name="EmployeeServiceBehaviour">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <services>
      <service behaviorConfiguration="EmployeeServiceBehaviour" name="EmployeeConfiguration">
        <endpoint address="http://localhost:2005/EmployeeService.svc" binding="basicHttpBinding"
          bindingConfiguration="" contract="IEmployeeConfiguration" />
      </service>
    </services>
  </system.serviceModel>
  <system.web>
    <compilation debug="true"/>
  </system.web>
  <system.webServer>
    <directoryBrowse enabled="true"/>
  </system.webServer>
</configuration>

请您解释一下,为什么我在提供地址时在IIS上出现空白页.

Could you please explain, why I get a blank page on IIS when I provide the adress.

推荐答案

我认为您可以删除Service.svc之前地址上的所有文本.这可能是使用不同网址的问题.

I think you can remove all text on the address before Service.svc. This might be an issue with different urls.

指定地址部分时,您告诉WCF该服务仅在该地址上可用.通过端点时,WCF将找不到与给定URL匹配的端点并进行纾困.

When you specify the address part, you tell WCF the service is only available on that address. When going through the endpoints, WCF will not find one that matches the given URL and bail out.

当您有多个端点时,您需要地址字段.否则,你不会.

When you have multiple endpoints you need the address field. Otherwise you don't.

阅读 http://msdn.microsoft.com/en-us/library/ms733749(v = vs.110).aspx

尤其是这部分:

使用IIS托管时,您不能自己管理ServiceHost实例.基址始终是在IIS中托管时在服务的.svc文件中指定的地址.因此,必须将相对端点地址用于IIS托管的服务端点.提供标准的端点地址可能会导致服务部署中的错误.

When hosting with IIS, you do not manage the ServiceHost instance yourself. The base address is always the address specified in the .svc file for the service when hosting in IIS. So you must use relative endpoint addresses for IIS-hosted service endpoints. Supplying a fully-qualified endpoint address can lead to errors in the deployment of the service.

这篇关于IIS托管的wcf返回我空白页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆