2

我有一个 WCF 服务,它与 SQL 服务器连接并获取一些数据,构造对象然后返回它。我使用简单的绑定,.NET 4.0,当您创建 WCF 服务时,我没有添加任何特殊设置,只是模板中的默认设置。

该服务在我的本地数据库上运行良好,但现在当我部署在服务器上时,我检查了时间,处理需要 7 微秒(第一个需要更多时间)但在到达开始处理之前,WCF每次需要3 秒在点击第一行代码之前请求,我找不到原因。

<endpoint address="http://localhost/Service.svc" binding="basicHttpBinding"
            bindingConfiguration="BasicHttpBinding_IService" contract="Local.IService"
            name="BasicHttpBinding_IService" />

谢谢!

服务行为:

    <behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false 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>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />

绑定:

    <bindings>
<basicHttpBinding>
        <binding name="BasicBinding" maxReceivedMessageSize="10485760" />
</basicHttpBinding>
</bindings>
4

1 回答 1

0

在请求到达 IIS 和到达 C# 代码之间发生的主要事情之一是安全检查。根据您的设置,您的开发机器上可能没有任何安全性。

假设您正在使用带有 NTLM 的 Windows 身份验证。然后有一个 3 请求握手与 http 、 401.2、 401.1 和 200 响应。在这些请求之间,您的 Web 服务器将与您的 AD 服务器通信。

您应该能够通过检查 IIS 日志来查看这是否是问题所在。

于 2013-03-27T20:11:43.177 回答