“/”中的服务器错误 使用 https 的 WCF REST 服务应用程序错误

Server Error in '/' Application error with a WCF REST service using https

我正在尝试在 https 服务器上托管 WCF REST 服务。服务器上的 IIS 管理器为 https 端口配置 属性,我的 Web.config 配置正确。但是,我只是在 ping URL 时收到此消息 "Server Error in '/' Application error"。 URL 匹配已配置为 IIS 应用程序的正确虚拟目录。它只是没有解决。我在此服务器上有另一个 WCF 服务,运行 很好,但它使用 basicHttpBinding,因为它是一个 soap 服务。

谁能看看我的 RESTful web.Config 看看我是不是看错了,因为肯定有问题?在没有所有 https 配置设置的情况下使用 http 部署在我的本地计算机上时,此服务工作正常,但在另一台 https 服务器上部署时,它不起作用。必须有一些我想念的东西。 Tnx.

    <?xml version="1.0"?>
    <configuration>
      <appSettings>
      </appSettings>
      <!-- SQL connection settings -->
      <connectionStrings>
      </connectionStrings>
      <!--
        For a description of web.config changes see http://go.microsoft.com/fwlink/?LinkId=235367.

        The following attributes can be set on the <httpRuntime> tag.
          <system.Web>
            <httpRuntime targetFramework="4.6" />
          </system.Web>
      -->
      <system.web>
        <compilation debug="true" targetFramework="4.6"/>
        <httpRuntime targetFramework="4.5"/>
      </system.web>
      <system.serviceModel>
        <client/>

        <bindings>
          <webHttpBinding>
            <binding name="secureHttpBinding" maxReceivedMessageSize="200000000">
              <security mode="Transport">
                <transport clientCredentialType="None"/>
              </security>
            </binding>
          </webHttpBinding>
          <mexHttpsBinding>
            <binding name="secureMexBinding"/>
          </mexHttpsBinding>
        </bindings>

        <behaviors>
          <!-- Required for json web service -->
          <endpointBehaviors>
            <behavior name="webBehavior">
              <webHttp/>
            </behavior>
          </endpointBehaviors>

          <serviceBehaviors>
            <behavior name="serviceBehaviors">
              <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
              <serviceMetadata httpGetEnabled="false" httpsGetEnabled="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>
        <services>
          <service behaviorConfiguration="serviceBehaviors" name="RepoWebService.MasterRepoAPI">
            <endpoint address="" behaviorConfiguration="webBehavior" binding="webHttpBinding" bindingConfiguration="secureHttpBinding" contract="StatuteRepoWebService.IRepoWebService.MasterRepoAPI"/>
            <endpoint address="mex" binding="mexHttpsBinding" bindingConfiguration="secureMexBinding" contract="IMetadataExchange"/>
          </service>
        </services>
        <protocolMapping>
          <add scheme="https" binding="webHttpBinding" bindingConfiguration="secureHttpBinding"/>
        </protocolMapping>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
      </system.serviceModel>
      <system.webServer>
        <modules runAllManagedModulesForAllRequests="true"/>
      </system.webServer>
      <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <dependentAssembly>
            <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral"/>
            <bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0"/>
          </dependentAssembly>
        </assemblyBinding>
      </runtime>
    </configuration>

我看你的服务配置文件没有问题。它只支持 Https 协议。托管环境可能存在一些问题。
我们应该在 IIS 绑定模块中提供一个 https 绑定,那么服务地址将是 https://x.x.x.x:xxxxx/service1.svc

此外,这是我使用 WCF4.5 新功能协议映射的简化配置。它同时支持 https 和 http。

<system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior>
          <webHttp />
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <bindings>
      <webHttpBinding>
        <binding name="mybinding">
          <security mode="Transport">
            <transport clientCredentialType="None"></transport>
          </security>
        </binding>
      </webHttpBinding>
    </bindings>
    <protocolMapping>
      <add binding="webHttpBinding" scheme="http"/>
      <add binding="webHttpBinding" scheme="https" bindingConfiguration="mybinding"/>
    </protocolMapping>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>

https://docs.microsoft.com/en-us/dotnet/framework/wcf/whats-new
如果有什么我可以帮忙的,请随时告诉我。