<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <!-- Config Sections for Custom Service Credentials -->
  <configSections>
    <section name="serviceCredentials" type="System.Configuration.NameValueSectionHandler" />
    <sectionGroup name="system.net">
      <section name="settings" type="System.Net.Configuration.SettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
    </sectionGroup>
  </configSections>

  <!-- Application Settings for web application -->
  <appSettings>
    <add key="ApplicationUsername" value="myAppUser" />
    <add key="ApplicationPassword" value="myAppPassword" />
    <add key="OAuthServiceUrl" value="https://oauth.example.com/token" />
    <add key="ClientId" value="myClientId" />
    <add key="ClientSecret" value="myClientSecret" />
    <add key="ServiceUrl" value="https://service.example.com/api" />
    <add key="ServiceUserName" value="serviceUser" />
    <add key="ServicePassword" value="servicePassword" />
    <add key="ApiEndpoint" value="https://api.example.com/endpoint" />
    <add key="ApiUserName" value="apiUser" />
    <add key="ApiPassword" value="apiPassword" />
  </appSettings>

  <!-- Custom service credentials -->
  <serviceCredentials>
    <add key="ServiceUrl" value="https://customservice.example.com" />
    <add key="UserName" value="customUser" />
    <add key="Password" value="customPassword" />
  </serviceCredentials>

  <!-- Connection strings for various databases -->
  <connectionStrings>
    <add name="SqlServerConnection"
         connectionString="Data Source=localhost;Initial Catalog=myDB;User ID=myUser;Password=myPass;"
         providerName="System.Data.SqlClient" />
    <add name="SqlServerIntegratedSecurity"
         connectionString="Data Source=localhost;Initial Catalog=myDB;Integrated Security=True;"
         providerName="System.Data.SqlClient" />
    <add name="MySqlConnection"
         connectionString="Server=localhost;Database=myDB;User=myUser;Password=myPass;"
         providerName="MySql.Data.MySqlClient" />
    <add name="PostgreSqlConnection"
         connectionString="Host=localhost;Port=5432;Database=myDB;Username=myUser;Password=myPass;"
         providerName="Npgsql" />
    <add name="OracleConnection"
         connectionString="Data Source=MyOracleDB;User Id=oracleUser;Password=oraclePass;"
         providerName="Oracle.ManagedDataAccess.Client" />
  </connectionStrings>

  <!-- Web-specific settings for forms authentication, session state, and errors -->
  <system.web>
    <!-- Compilation settings -->
    <compilation debug="true" targetFramework="4.0" />

    <!-- Authentication settings for web applications -->
    <authentication mode="Forms">
      <forms loginUrl="login.aspx" timeout="30">
        <credentials passwordFormat="Clear">
          <user name="user1" password="password1" />
          <user name="user2" password="password2" />
        </credentials>
      </forms>
    </authentication>

    <!-- Authorization settings to allow or deny user access -->
    <authorization>
      <allow users="*" /> <!-- Allow all users -->
      <deny users="?" /> <!-- Deny anonymous users -->
    </authorization>

    <!-- Custom error pages -->
    <customErrors mode="RemoteOnly">
      <error statusCode="404" redirect="404.aspx" />
      <error statusCode="500" redirect="500.aspx" />
    </customErrors>

    <!-- Session State settings (optional) -->
    <sessionState mode="InProc" timeout="20" />
  </system.web>

  <!-- SMTP settings for email (relevant for web applications) -->
  <system.net>
    <mailSettings>
      <smtp from="you@example.com">
        <network host="smtp.example.com" port="587"
                 userName="smtpUser"
                 password="smtpPassword"
                 defaultCredentials="false" />
      </smtp>
    </mailSettings>
  </system.net>

  <!-- WCF (Windows Communication Foundation) Service configuration for web applications -->
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="MyBinding">
          <security mode="Transport">
            <transport clientCredentialType="Basic" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="https://example.com/service"
                binding="basicHttpBinding"
                bindingConfiguration="MyBinding"
                contract="IMyService" />
    </client>
    <behaviors>
      <endpointBehaviors>
        <behavior>
          <clientCredentials>
            <userName userName="serviceUser" password="servicePassword" />
          </clientCredentials>
        </behavior>
      </endpointBehaviors>
    </behaviors>
  </system.serviceModel>

  <!-- IIS-specific settings for URL rewriting and other web server configurations -->
  <system.webServer>
    <!-- Enable URL rewriting (optional) -->
    <rewrite>
      <rules>
        <rule name="RedirectToHTTPS">
          <match url="(.*)" />
          <conditions>
            <add input="{HTTPS}" pattern="^OFF$" />
          </conditions>
          <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" />
        </rule>
      </rules>
    </rewrite>

    <!-- Enable static content compression (optional) -->
    <staticContent>
      <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="7.00:00:00" />
    </staticContent>

    <!-- HTTP modules and handlers (optional) -->
    <modules runAllManagedModulesForAllRequests="true" />
  </system.webServer>

</configuration>
