SharePoint 2013 runs on ASP.NET Web Forms 4.5.  The Web.Config has been substantially overhauled in this version.  The root configuration files (machine.config file and the root web.config file) for the .NET Framework 4 (and therefore ASP.NET 4) have been updated to include most of the boilerplate configuration information that in ASP.NET 3.5 was found in the application web.config files. Because of the complexity of the managed IIS 7.5 configuration systems, running ASP.NET 3.5 applications under ASP.NET 4 and IIS 7.5 can result in either ASP.NET or IIS configuration errors.

When any PowerShell cmdlet is run under IIS 7.5, to access and modify web.config of SP15 application, it may result in error. For e.g. when these cmdlets are run, it may result in error.

Import-Module WebAdministration 
$iisSiteName = (Get-Website | ? {$_.physicalPath -match ".*\\VirtualDirectories\\80$"}).Name 
$webconfigfile = Get-WebConfigFile "IIS:\Sites\$iisSiteName"

Error message – ”The configuration section 'system.web.extensions' cannot be read because it is missing a section declaration”

This error happens because in ASP.NET 4.0, the following section in Web.config is removed and when PowerShell tries to read this section it results in error.

 

<sectionGroup name="system.web.extensions" 
        type="System.Web.Configuration.SystemWebExtensionsSectionGroup, 
        System.Web.Extensions, Version=4.0.0.0, Culture=neutral, 
        PublicKeyToken=31bf3856ad364e35">
      <sectionGroup name="scripting" 
        type="System.Web.Configuration.ScriptingSectionGroup, 
        System.Web.Extensions, Version=4.0.0.0, Culture=neutral, 
        PublicKeyToken=31bf3856ad364e35">
          <section name="scriptResourceHandler" 
            type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, 
            System.Web.Extensions, Version=4.0.0.0, 
            Culture=neutral, PublicKeyToken=31bf3856ad364e35" 
            requirePermission="false" 
            allowDefinition="MachineToApplication"/>
        <sectionGroup name="webServices" 
            type="System.Web.Configuration.ScriptingWebServicesSectionGroup, 
            System.Web.Extensions, Version=4.0.0.0, 
            Culture=neutral, PublicKeyToken=31bf3856ad364e35">
          <section name="jsonSerialization" 
              type="System.Web.Configuration.ScriptingJsonSerializationSection, 
              System.Web.Extensions, Version=4.0.0.0, 
              Culture=neutral, PublicKeyToken=31bf3856ad364e35" 
              requirePermission="false" allowDefinition="Everywhere" />
          <section name="profileService" 
              type="System.Web.Configuration.ScriptingProfileServiceSection, 
              System.Web.Extensions, Version=4.0.0.0, 
              Culture=neutral, PublicKeyToken=31bf3856ad364e35" 
              requirePermission="false" 
              allowDefinition="MachineToApplication" />
          <section name="authenticationService" 
              type="System.Web.Configuration.ScriptingAuthenticationServiceSection, 
              System.Web.Extensions, Version=4.0.0.0, 
              Culture=neutral, PublicKeyToken=31bf3856ad364e35" 
              requirePermission="false" 
              allowDefinition="MachineToApplication" />
        </sectionGroup>

</sectionGroup>

 

 

 

 

 

 

 

When the same script is run under IIS 8.0, it should work fine as IIS 8.0 PowerShell does recognize this change in Web Configuration.