被"远程服务器返回错误:(403)禁止"与WCF服务在https中难倒

RJ.*_*RJ. 12 .net c# asp.net wcf

我有一个WCF服务,由于这个错误我已经归结为几乎没有.它把我推到了墙上.这就是我现在拥有的.

一个非常简单的WCF服务,其中一个方法返回一个值为"test"的字符串.

一个非常简单的Web应用程序,它使用该服务并将字符串的值放入标签中.

在Win 2003上运行IIS 6且具有SSL证书的Web服务器.

有效的同一服务器上的其他WCF服务.

我将WCF服务发布到它的https位置

我在VS中以调试模式运行Web应用程序,它运行良好.

我将Web应用程序发布到WCF服务所在的同一服务器上的https位置,该服务器位于相同的SSL证书下

我明白了,"远程服务器返回错误:(403)Forbidden"

我几乎已经改变了IIS中的每个设置以及WCF和Web应用程序都无济于事.我已经比较了WCF服务中的设置和一切都是一样的.

以下是WCF服务和WEB应用程序的web.config中的设置:

看来这个问题与Web应用程序有关,但我没有想法.有任何想法吗:

WCF服务:

  <system.serviceModel>
<bindings>
Run Code Online (Sandbox Code Playgroud)

<client />

<services>
  <service behaviorConfiguration="Ucf.Smtp.Wcf.SmtpServiceBehavior" name="Ucf.Smtp.Wcf.SmtpService">
    <host>
      <baseAddresses>
        <add baseAddress="https://test.net.ucf.edu/webservices/Smtp/" />
      </baseAddresses>
    </host>
    <endpoint address="" binding="wsHttpBinding" contract="Ucf.Smtp.Wcf.ISmtpService" bindingConfiguration="SSLBinding">
      <identity>
        <dns value="localhost"/>
      </identity>
    </endpoint>
    <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>
  </service>
</services>

<behaviors>
  <serviceBehaviors>
    <behavior name="Ucf.Smtp.Wcf.SmtpServiceBehavior">
      <serviceMetadata httpsGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true" httpsHelpPageEnabled="True"/>
    </behavior>
  </serviceBehaviors>
</behaviors>
Run Code Online (Sandbox Code Playgroud)

网络应用:

    <system.serviceModel>
    <bindings><wsHttpBinding>
<binding name="WSHttpBinding_ISmtpService" closeTimeout="00:01:00"
 openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
 bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
 maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text"
 textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
 <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
  maxBytesPerRead="4096" maxNameTableCharCount="16384" />
 <reliableSession ordered="true" inactivityTimeout="00:10:00"
  enabled="false" />
 <security mode="Transport">
  <transport clientCredentialType="None" proxyCredentialType="None"
   realm="" />
  <message clientCredentialType="Windows" negotiateServiceCredential="true"
   establishSecurityContext="true" />
 </security>
</binding>
Run Code Online (Sandbox Code Playgroud)

<client>


<endpoint address="https://net228.net.ucf.edu/webservices/smtp/SmtpService.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_ISmtpService"
contract="SmtpService.ISmtpService" name="WSHttpBinding_ISmtpService">
<identity>
 <dns value="localhost" />
</identity>
Run Code Online (Sandbox Code Playgroud)

  </client>
</system.serviceModel>
Run Code Online (Sandbox Code Playgroud)

RJ.*_*RJ. 5

在花了很多时间研究这个问题之后,我将回答我自己的问题。我希望这能帮助所有其他为解决这个问题而苦苦挣扎的人。我们最终让网络管理员参与并解决了这个问题。

这是场景和解决方案:

我们有一个生产服务器 - 一切正常。我们有一个测试服务器 - 我们收到 403 禁止错误。本地调试工作正常。

所有的设置都是相同的,至少我们是这么认为的。

有一个设置是错误的。在 IIS 中,在“目录安全”选项卡下的 Web 服务虚拟目录属性中,第二个“编辑”按钮用于 IP 限制。我们设置为拒绝访问除应包含测试服务器 IP 的列表之外的所有 IP。测试网络服务器的 IP 未授予权限。它没有权限的原因是它最近是从生产虚拟服务器克隆的,并且从未调整此设置以添加测试虚拟服务器。