在IIS上配置WCF服务

时间:2012-01-23 18:05:07

标签: c# .net wcf iis deployment

这是我第一次使用WCF。开发应用程序非常容易,但它让我很难在IIS上部署。

我已经尝试了部署它,但是客户端开始将未经授权的用户异常(或类似的东西)抛给未定义的异常(在web.config文件和app.config文件中进行了无数次更改之后)。

我回到默认配置,在VS(cassini)中工作正常。

任何快速指针或指向详细教程的链接都将非常感激。

提前致谢

<system.serviceModel>
    <services>
      <service behaviorConfiguration="MBTService.Service1Behavior"
        name="MBTService.MBTService">
        <endpoint address="" binding="wsHttpBinding" contract="MBTSTBO.IMBTService">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="MBTService.Service1Behavior">
          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="true"/>
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

2 个答案:

答案 0 :(得分:0)

并非特定于您的情况,但WCF跟踪通常是诊断WCF配置问题的非常好的工具。您可以看到here如何配置WCF跟踪,它非常简单,WCF运行时基本上会将一些信息发送到.svclog文件中

然后,您可以使用Service Trace Viewer Tool(它位于所有程序 - &gt; Visual Studio 2010-&gt; Microsoft Windows SDK工具)中分析日志,并查看特定请求期间出现的问题,它提供了更多内容信息比异常消息。

答案 1 :(得分:0)

强尼,

这是一个很长的镜头,但一旦我遇到同样的问题(未经授权的访问),问题是一些文件(从网络邮件下载)被Windows阻止。一旦我解锁了这些文件,Web服务就开始正常工作了。

希望它有所帮助。