<?xml version="1.0"?>
<configuration>

  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true"/>
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.5.2"/>
    <httpRuntime targetFramework="4.5.2"/>
    <httpModules>
      <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web"/>
    </httpModules>
  </system.web>
  <system.serviceModel>
    <behaviors>
      <!-- Add endpointBehaviors here !! (Mike)
      http://msdn.microsoft.com/en-us/library/ms733932.aspx
      -->
      <endpointBehaviors>
        <behavior name="AjaxBehavior">
          <!-- name: used to identify behaviour below-->
          <!-- <webHtp/> enables the Web programming model with WCF, by default returns XML-->
          <!--<enableWebScript/> Alternatively, specify ASP.AJAX approach to return dynamic JavaScript -->
          <webHttp/>
        </behavior>
      </endpointBehaviors>
        
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
          <serviceMetadata httpGetEnabled="true" 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>
    
    <!-- Add services here !! (Mike) -->
    <services>

      <!-- <service> the "name" is the C# class that implements the interface (or contract) -->
      <service name="CorsService.MessageService">
        <!--
        Can have multiple endpoints for service, so that you can access it in multiple ways.
        
        "address": 
        Specifies the service's Uniform Resource Identifier (URI), which can be an absolute 
        address or one that is given relative to the base address of the service. 
        You will need to add a URL route (see ASP MapPageRoute) to get to work.        
        If set to an empty string, it indicates that the endpoint is available at the 
        base address e.g. http://localhost for ASP application
       
       "behaviorConfiguration":
        Link to behaviour specified above
        
        "binding":
        The binding specified determines the type of transport, security and encoding used, and whether
        reliable sessions, transactions, or streaming is supported or enabled.
        
        "contract":
        Specifies the C# interface that defines the contract.        
        -->
        <endpoint
            address=""
            behaviorConfiguration="AjaxBehavior"
            binding="webHttpBinding"
            contract="CorsService.IMessageService" />
        <!--
        NOT REQD when hosting in IIS
        If self hosting, can set up baseAddresses
        ... self hosting = write code to execute service yourself
        e.g. using a console application.
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost/"/>
          </baseAddresses>
        </host>-->
      </service>
    </services>      
    
    <protocolMapping>
        <add binding="basicHttpsBinding" scheme="https"/>
    </protocolMapping>    
    <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>
    <!--
        To browse web app root directory during debugging, set the value below to true.
        Set to false before deployment to avoid disclosing web app folder information.
      -->
    <directoryBrowse enabled="true"/>
    <validation validateIntegratedModeConfiguration="false"/>
  </system.webServer>

</configuration>
