0

It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS.

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

I understand this is a very common and ambiguous error, and that there's a ton of questions about it already, but none of them have solved my issue. So I'll try to be more thorough and specific:

It's a WCFService that I'm publishing to an external IIS server via FTP. I get this error when I try to view the site in my browser at https://www.domain.com/correctdirectory/JobsService.svc

This is my 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>

And here's the things I've made sure:

  1. Project is cleaned in both Debug and Release mode.
  2. Project is built in Debug mode.
  3. The Web.config in the IIS root does not conflict with this Web.config. It basically just enforces https, and handles different filetype requests.
  4. The service is hosted as an application on the IIS (not just a virtual directory)

It works fine when I publish it to a server on the internal network, that has no other websites or services.

I know there's a lot of other applications on the server I'm trying to publish to, but my application is at the root level, so that shouldn't matter, right? If it matters, I also know that at least one of those applications is an ASMX web service. The owner of the server doesn't know the problem either.

I've also tried downgrading my project to .NET 4.0, since I know his ASMX service runs on that.

Any ideas?

Community
  • 1
  • 1
Aske B.
  • 6,419
  • 8
  • 35
  • 62

1 Answers1

0

I had already tried moving the directory to the root of the virtual directory, via an external FTP Client (Total Commander), without success, but when I used Visual Studio's built in publishing tool and made sure to have an empty Site Path, it finally started working.

I'm still not sure why that is, but I guess I'll do some research on it another time, when I get time. If anyone knows, comments would be very much appreciated!

Aske B.
  • 6,419
  • 8
  • 35
  • 62