【问题标题】:Publishing WCF Service to external IIS server with other applications使用其他应用程序将 WCF 服务发布到外部 IIS 服务器
【发布时间】:2016-10-03 20:09:35
【问题描述】:

在应用程序级别之外使用注册为 allowDefinition='MachineToApplication' 的部分是错误的。此错误可能是由于虚拟目录未在 IIS 中配置为应用程序所致。

    </service>
  </services>
  <serviceHostingEnvironment aspNetCompatibilityEnabled="true"
      multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>

我知道这是一个非常常见且模棱两可的错误,并且已经有很多关于它的问题,但没有一个能够解决我的问题。所以我会尝试更彻底和具体:

这是我通过 FTP 发布到外部 IIS 服务器的 WCFService。当我尝试在浏览器中查看https://www.domain.com/correctdirectory/JobsService.svc 的站点时出现此错误

这是我的Web.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=*token*" requirePermission="false" />
  </configSections>
  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.5.1" />
    <httpRuntime targetFramework="4.5.1" />
    <customErrors mode="Off"></customErrors>
    <httpModules>
    </httpModules>
  </system.web>

  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <protocolMapping>
      <add binding="basicHttpsBinding" scheme="https" />
    </protocolMapping>
    <bindings>
      <basicHttpBinding>
        <binding name="basicHttpBindingConfiguration">
          <security mode="Transport">
            <transport clientCredentialType="None" proxyCredentialType="None"/>
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <services>
      <service name="WcfServiceAPI.Services.Validation.ValidationService">
        <endpoint address="" binding="basicHttpBinding" bindingConfiguration="basicHttpBindingConfiguration" contract="WcfServiceAPI.Services.Validation.IValidationService"/>
      </service>
      <service name="WcfServiceAPI.Services.Jobs.JobsService">
        <endpoint address="" binding="basicHttpBinding" bindingConfiguration="basicHttpBindingConfiguration" contract="WcfServiceAPI.Services.Jobs.IJobsService"/>
      </service>
    </services>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true">
      <remove name="ApplicationInsightsWebTracking" />
      <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" preCondition="managedHandler" />
    </modules>
    <directoryBrowse enabled="true" />
    <validation validateIntegratedModeConfiguration="false" />
  </system.webServer>
  <entityFramework>
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
  </entityFramework>
</configuration>

这是我确定的事情:

  1. 项目是cleaned in both Debug and Release mode
  2. 项目在调试模式下构建。
  3. IIS 根目录中的 Web.config 与此 Web.config 不冲突。它基本上只是强制执行 https,并处理不同的文件类型请求。
  4. 服务作为应用程序托管在 IIS 上(不仅仅是虚拟目录)

当我将它发布到没有其他网站或服务的内部网络上的服务器时,它工作正常。

我知道在我尝试发布到的服务器上还有很多其他应用程序,但我的应用程序处于根级别,所以这不重要,对吧? 如果重要的话,我还知道这些应用程序中至少有一个是 ASMX Web 服务。服务器的所有者也不知道问题所在。

我也尝试将我的项目降级到 .NET 4.0,因为我知道他的 ASMX 服务运行在上面。

有什么想法吗?

【问题讨论】:

    标签: web-services wcf iis


    【解决方案1】:

    我已经尝试通过外部 FTP 客户端(Total Commander)将目录移动到虚拟目录的根目录,但没有成功,但是当我使用 Visual Studio 的内置发布工具并确保有一个 Site Path,它终于开始工作了。

    我仍然不确定为什么会这样,但我想我会在下次有时间的时候对它进行一些研究。如果有人知道,cmets 将不胜感激!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-10-24
      • 2016-04-02
      • 1970-01-01
      • 2018-05-24
      • 2016-04-14
      • 1970-01-01
      • 2016-08-17
      相关资源
      最近更新 更多