title: Modifying a web.config in ASP.NET 4.0
body: <p>I have a VB project that I have been assigned. My VB is not great, and my preference is C#, so I converted the code.</p>
  
  <p>Converting the code was straight forward, but getting a <strong>Web.config</strong> file that works is causing me lots of headaches.</p>
  
  <p>The VB project was started with ASP.NET 2.0 and upgraded with 3.5 features.</p>
  
  <p>Here are the full Web Config files, in all their gory details, starting with the VB <strong>web.config</strong> file:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;configuration&gt;
    &lt;configSections&gt;
      &lt;sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"&gt;
        &lt;sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"&gt;
          &lt;section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/&gt;
          &lt;sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"&gt;
            &lt;section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere"/&gt;
            &lt;section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/&gt;
            &lt;section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/&gt;
            &lt;section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/&gt;
          &lt;/sectionGroup&gt;
        &lt;/sectionGroup&gt;
      &lt;/sectionGroup&gt;
    &lt;/configSections&gt;
    &lt;appSettings/&gt;
  &lt;connectionStrings&gt;
    &lt;add name="MaintenanceConnectionString" connectionString="Data Source=data1;Initial Catalog=Catalog1;User Id=abc123;Password=abc123;" providerName="System.Data.SqlClient"/&gt;
  &lt;/connectionStrings&gt;
  &lt;system.net&gt;
    &lt;mailSettings&gt;
      &lt;smtp&gt;
        &lt;network host="172.16.8.200" port="25"/&gt;
      &lt;/smtp&gt;
    &lt;/mailSettings&gt;
  &lt;/system.net&gt;
  &lt;system.web&gt;
    &lt;compilation debug="true" strict="false" explicit="true"&gt;
      &lt;assemblies&gt;
        &lt;add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/&gt;
        &lt;add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/&gt;
        &lt;add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/&gt;
        &lt;add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/&gt;
        &lt;add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/&gt;
        &lt;add assembly="System.Web.Extensions.Design, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/&gt;
        &lt;add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/&gt;
        &lt;add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/&gt;
        &lt;add assembly="Microsoft.ReportViewer.WebForms, Version=9.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/&gt;
        &lt;add assembly="Microsoft.ReportViewer.Common, Version=9.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/&gt;
      &lt;/assemblies&gt;
      &lt;buildProviders&gt;
        &lt;add extension=".rdlc" type="Microsoft.Reporting.RdlBuildProvider, Microsoft.ReportViewer.Common, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/&gt;
      &lt;/buildProviders&gt;
    &lt;/compilation&gt;
    &lt;pages&gt;
      &lt;namespaces&gt;
        &lt;clear/&gt;
        &lt;add namespace="System"/&gt;
        &lt;add namespace="System.Collections"/&gt;
        &lt;add namespace="System.Collections.Generic"/&gt;
        &lt;add namespace="System.Collections.Specialized"/&gt;
        &lt;add namespace="System.Configuration"/&gt;
        &lt;add namespace="System.Text"/&gt;
        &lt;add namespace="System.Text.RegularExpressions"/&gt;
        &lt;add namespace="System.Web"/&gt;
        &lt;add namespace="System.Web.Caching"/&gt;
        &lt;add namespace="System.Web.SessionState"/&gt;
        &lt;add namespace="System.Web.Security"/&gt;
        &lt;add namespace="System.Web.Profile"/&gt;
        &lt;add namespace="System.Web.UI"/&gt;
        &lt;add namespace="System.Web.UI.WebControls"/&gt;
        &lt;add namespace="System.Web.UI.WebControls.WebParts"/&gt;
        &lt;add namespace="System.Web.UI.HtmlControls"/&gt;
      &lt;/namespaces&gt;
      &lt;controls&gt;
        &lt;add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/&gt;
        &lt;add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/&gt;
      &lt;/controls&gt;
    &lt;/pages&gt;
    &lt;authentication mode="Windows" /&gt;
    &lt;customErrors mode="Off"/&gt;
    &lt;httpHandlers&gt;
      &lt;remove path="*.asmx" verb="*"/&gt;
      &lt;add path="*.asmx" verb="*" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/&gt;
      &lt;add path="*_AppService.axd" verb="*" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/&gt;
      &lt;add path="ScriptResource.axd" verb="GET,HEAD" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/&gt;
      &lt;add path="Reserved.ReportViewerWebControl.axd" verb="*" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" validate="false"/&gt;
    &lt;/httpHandlers&gt;
    &lt;httpModules&gt;
      &lt;add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/&gt;
    &lt;/httpModules&gt;
  &lt;/system.web&gt;
  &lt;system.codedom&gt;
    &lt;compilers&gt;
      &lt;compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CSharp.CSharpCodeProvider,System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="4"&gt;
        &lt;providerOption name="CompilerVersion" value="v3.5"/&gt;
        &lt;providerOption name="WarnAsError" value="false"/&gt;
      &lt;/compiler&gt;
      &lt;compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="4"&gt;
        &lt;providerOption name="CompilerVersion" value="v3.5"/&gt;
        &lt;providerOption name="OptionInfer" value="true"/&gt;
        &lt;providerOption name="WarnAsError" value="false"/&gt;
      &lt;/compiler&gt;
    &lt;/compilers&gt;
  &lt;/system.codedom&gt;
  &lt;system.webServer&gt;
    &lt;validation validateIntegratedModeConfiguration="false"/&gt;
    &lt;modules&gt;
      &lt;remove name="ScriptModule"/&gt;
      &lt;add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/&gt;
    &lt;/modules&gt;
    &lt;handlers&gt;
      &lt;remove name="WebServiceHandlerFactory-Integrated"/&gt;
      &lt;remove name="ScriptHandlerFactory"/&gt;
      &lt;remove name="ScriptHandlerFactoryAppServices"/&gt;
      &lt;remove name="ScriptResource"/&gt;
      &lt;add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/&gt;
      &lt;add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/&gt;
      &lt;add name="ScriptResource" verb="GET,HEAD" path="ScriptResource.axd" preCondition="integratedMode" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/&gt;
    &lt;/handlers&gt;
  &lt;/system.webServer&gt;
  &lt;runtime&gt;
    &lt;assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"&gt;
      &lt;dependentAssembly&gt;
        &lt;assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35"/&gt;
        &lt;bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/&gt;
      &lt;/dependentAssembly&gt;
      &lt;dependentAssembly&gt;
        &lt;assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35"/&gt;
        &lt;bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/&gt;
      &lt;/dependentAssembly&gt;
    &lt;/assemblyBinding&gt;
  &lt;/runtime&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>In my efforts to try and get the integrated Windows security to work, I have tried to duplicate most of its structure in this C# <strong>Web.config</strong> file:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;configuration&gt;
    &lt;configSections&gt;
      &lt;sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"&gt;
        &lt;sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"&gt;
          &lt;sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"&gt;
            &lt;section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere"/&gt;
            &lt;section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/&gt;
            &lt;section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/&gt;
            &lt;section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/&gt;
          &lt;/sectionGroup&gt;
        &lt;/sectionGroup&gt;
      &lt;/sectionGroup&gt;
    &lt;/configSections&gt;
    &lt;appSettings&gt;
      &lt;add key="WAREHOUSE" value="http:\\web2\Warehouse.aspx" /&gt;
      &lt;add key="WAREHOUSE_STATUS" value="http:\\web2\WarehouseStatus.aspx" /&gt;
    &lt;/appSettings&gt;
    &lt;connectionStrings&gt;
      &lt;add name="WEB2" connectionString="Data Source=data2;Initial Catalog=Catalog2;User Id=abc123;Password=abc123;" providerName="System.Data.SqlClient" /&gt;
    &lt;/connectionStrings&gt;
    &lt;system.net&gt;
      &lt;mailSettings&gt;
        &lt;smtp&gt;
          &lt;network host="172.16.8.200" port="25"/&gt;
        &lt;/smtp&gt;
      &lt;/mailSettings&gt;
    &lt;/system.net&gt;
    &lt;system.web&gt;
      &lt;authentication mode="Windows" /&gt;
        &lt;compilation debug="true" targetFramework="4.0"&gt;
          &lt;assemblies&gt;
            &lt;add assembly="Microsoft.ReportViewer.Common, Version=9.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/&gt;
            &lt;add assembly="Microsoft.ReportViewer.WebForms, Version=9.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/&gt;
            &lt;add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/&gt;
            &lt;add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/&gt;
            &lt;add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" /&gt;
            &lt;add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/&gt;
            &lt;add assembly="System.Web.Extensions.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /&gt;
            &lt;add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" /&gt;
            &lt;add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/&gt;
            &lt;add assembly="*"/&gt;
          &lt;/assemblies&gt;
          &lt;buildProviders&gt;
            &lt;add extension=".rdlc" type="Microsoft.Reporting.RdlBuildProvider, Microsoft.ReportViewer.Common, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/&gt;
          &lt;/buildProviders&gt;
        &lt;/compilation&gt;
      &lt;customErrors mode="Off" /&gt;
      &lt;pages&gt;
        &lt;namespaces&gt;
          &lt;clear/&gt;
          &lt;add namespace="System"/&gt;
          &lt;add namespace="System.Collections"/&gt;
          &lt;add namespace="System.Collections.Generic"/&gt;
          &lt;add namespace="System.Collections.Specialized"/&gt;
          &lt;add namespace="System.Configuration"/&gt;
          &lt;add namespace="System.Text"/&gt;
          &lt;add namespace="System.Text.RegularExpressions"/&gt;
          &lt;add namespace="System.Web"/&gt;
          &lt;add namespace="System.Web.Caching"/&gt;
          &lt;add namespace="System.Web.Security"/&gt;
          &lt;add namespace="System.Web.SessionState"/&gt;
          &lt;add namespace="System.Web.Profile"/&gt;
          &lt;add namespace="System.Web.UI"/&gt;
          &lt;add namespace="System.Web.UI.HtmlControls"/&gt;
          &lt;add namespace="System.Web.UI.WebControls"/&gt;
          &lt;add namespace="System.Web.UI.WebControls.WebParts"/&gt;
        &lt;/namespaces&gt;
        &lt;controls&gt;
          &lt;add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/&gt;
          &lt;add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/&gt;
        &lt;/controls&gt;
      &lt;/pages&gt;
      &lt;trace enabled="true" /&gt;
      &lt;httpHandlers&gt;
        &lt;remove path="*.asmx" verb="*"/&gt;
        &lt;add path="*.asmx" verb="*" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/&gt;
        &lt;add path="*_AppService.axd" verb="*" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/&gt;
        &lt;add path="ScriptResource.axd" verb="GET,HEAD" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/&gt;
        &lt;add path="Reserved.ReportViewerWebControl.axd" verb="*" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" validate="false"/&gt;
      &lt;/httpHandlers&gt;
      &lt;httpModules&gt;
        &lt;add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/&gt;
      &lt;/httpModules&gt;
    &lt;/system.web&gt;
    &lt;bindings /&gt;
    &lt;client /&gt;
    &lt;behaviors&gt;
      &lt;serviceBehaviors&gt;
        &lt;behavior name="debug"&gt;
          &lt;serviceDebug includeExceptionDetailInFaults="true" /&gt;
        &lt;/behavior&gt;
        &lt;behavior name="serviceTypeBehaviors"&gt;
          &lt;serviceMetadata httpGetEnabled="true" /&gt;
          &lt;serviceDebug includeExceptionDetailInFaults="true" /&gt;
          &lt;serviceCredentials&gt;
            &lt;clientCertificate&gt;
              &lt;authentication certificateValidationMode="None" mapClientCertificateToWindowsAccount="true" /&gt;
            &lt;/clientCertificate&gt;
          &lt;/serviceCredentials&gt;
        &lt;/behavior&gt;
        &lt;behavior name=""&gt;
          &lt;serviceMetadata httpGetEnabled="true" /&gt;
          &lt;serviceDebug includeExceptionDetailInFaults="true" /&gt;
        &lt;/behavior&gt;
      &lt;/serviceBehaviors&gt;
    &lt;/behaviors&gt;
    &lt;serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true"&gt;
      &lt;serviceActivations&gt;
        &lt;add factory="System.ServiceModel.Activation.ServiceHostFactory" relativeAddress="~/mainframe/MainFrame.svc" service="AcpServiceNS.MainFrameService" /&gt;
      &lt;/serviceActivations&gt;
    &lt;/serviceHostingEnvironment&gt;
    &lt;services&gt;
      &lt;service behaviorConfiguration="serviceTypeBehaviors" name="AcpServiceNS.AcpCoilService"&gt;
        &lt;endpoint address="" binding="basicHttpBinding" contract="AcpServiceNS.IAcpCoilService" /&gt;
        &lt;endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /&gt;
      &lt;/service&gt;
      &lt;service behaviorConfiguration="serviceTypeBehaviors" name="AcpServiceNS.AcpEmployee"&gt;
        &lt;endpoint address="" binding="basicHttpBinding" contract="AcpServiceNS.IAcpEmployee" /&gt;
        &lt;endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /&gt;
      &lt;/service&gt;
      &lt;service behaviorConfiguration="serviceTypeBehaviors" name="AcpServiceNS.AcpPackout"&gt;
        &lt;endpoint address="" binding="basicHttpBinding" contract="AcpServiceNS.IAcpPackout" /&gt;
        &lt;endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /&gt;
      &lt;/service&gt;
      &lt;service behaviorConfiguration="serviceTypeBehaviors" name="AcpServiceNS.ErpService"&gt;
        &lt;endpoint address="" binding="basicHttpBinding" contract="AcpServiceNS.IErpData" /&gt;
        &lt;endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /&gt;
      &lt;/service&gt;
      &lt;service behaviorConfiguration="serviceTypeBehaviors" name="AcpServiceNS.MainFrameService"&gt;
        &lt;endpoint address="" binding="basicHttpBinding" contract="AcpServiceNS.IMainFrameService" /&gt;
        &lt;endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /&gt;
      &lt;/service&gt;
    &lt;/services&gt;
  &lt;/system.serviceModel&gt;
  &lt;system.webServer&gt;
    &lt;validation validateIntegratedModeConfiguration="false"/&gt;
    &lt;modules&gt;
      &lt;remove name="ScriptModule"/&gt;
      &lt;add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/&gt;
    &lt;/modules&gt;
    &lt;handlers&gt;
      &lt;remove name="WebServiceHandlerFactory-Integrated"/&gt;
      &lt;remove name="ScriptHandlerFactory"/&gt;
      &lt;remove name="ScriptHandlerFactoryAppServices"/&gt;
      &lt;remove name="ScriptResource"/&gt;
      &lt;add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/&gt;
      &lt;add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/&gt;
      &lt;add name="ScriptResource" verb="GET,HEAD" path="ScriptResource.axd" preCondition="integratedMode" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/&gt;
    &lt;/handlers&gt;
  &lt;/system.webServer&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>Everytime I try to run my project, I get another error from localhost IIS 8.0, like the 500.19 error below:</p>
  
  <blockquote>
    <p>The requested page cannot be accessed because the related configuration data for the page is invalid.</p>
  </blockquote>
  
  <p><strong>Detailed Error Information:</strong><br>
  <strong>Config Error</strong> There is a duplicate 'system.web.extensions/scripting/webServices/jsonSerialization' section defined</p>
  
  <p>In the <strong>Config Source:</strong> section, it is pointing to Line 7:</p>
  
  <pre><code> &lt;section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere"/&gt;
  </code></pre>
  
  <p>I suppose I should change all of these to use Version 4.0.0.0, but I'm not sure where to get the Public Key Token from, if there is a 4.0 version on my machine, or if I have this defined elsewhere already (I was not able to find another <code>jsonSerialization</code> section with a document search).</p>
  
  <h2>How do I fix this?</h2>
  
  <h2>Is there a way for Visual Studio 2010 to rebuild a proper <strong>Web.config</strong> file?</h2>