'System.Web.Extensions' trouble deploying .Net Framework 4 Website on IIS7

36,510

Solution 1

You can also get this very same error if you create a new website in IIS 7(.5) as the application pool it creates for the new site may still be set to 2.0, and as such, system.web.extensions is not valid in a 2.0 configuration file.

Simply go into IIS Manager, choose the application pools, select the one for your app, right-click, Advanced Settings and set .NET framework version to v4.

Solution 2

Module  IIS Web Core
Notification    BeginRequest
Handler Not yet determined
Error Code  0x80070032
Config Error    The configuration section 'system.web.extensions' cannot be read because it is missing a section declaration 
Config File \\web.config

The error is due to this system.web.extensions section added to the Web.config

<system.web.extensions>
<scripting>
<webServices>
<!-- Uncomment this line to customize maxJsonLength and add a custom converter
   <jsonSerialization maxJsonLength="1024000">
-->
</webServices>
<scriptResourceHandler enableCompression="true" enableCaching="true"/>
</scripting>
</system.web.extensions>

For some reason adding that section, overrides the system.web.extensions group. The solution is to

  1. Comment the code above if you don't need it.
  2. Add the code below to the Web.config section group

..

<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" />
        <section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication" />
    </sectionGroup>
</sectionGroup>
</sectionGroup>

Solution 3

I could solve this issue myself after some hunting around (happens!).

apparently has nothing to do with the way the config file is structured, it is the assembly for ASP.Net Ajax which is not deployed on my target server but might be present on my dev machine.

I deleted the entry from the web.config file and this issue was resolved, there were some other minor issues but nothing worth mentioning.

The deployment experience for IIS7+.Net Framework 4 wasn't too difficult and the added capabilities will going to be worth it.

Solution 4

If "aspnet_regiis.exe -iru" don't help and you sure, that you try to launch site under .NET 4.0 App pool, it may be the problem in configuration inheritance of IIS 7.0. Web server reads machine.config of .NET 2.0. Applying of hotfix KB958854 would solve the problem with configuration inheritance. I have successfully fixed my problem in this way.

Solution 5

I found the answer from Leo Tang post:

This issue not caused by the web.config migration. If you update you application to .Net Framework4.0, but assign this application to an application pool running under .Net Framework3.5 or previous version, you will encounter this error. You can assign this application to an .Net Framework4.0 application pool in IIS to fix issue.

So, if you read the error The configuration section 'system.web.extensions' cannot be read because it is missing a section declaration it’s because the application you have deployed is running under an application pool configured to run under .NET 2.0 or 3.5 (DefaultAppPool? DefaultAppPool by default is set to .NET 2.0).

Perform the following steps:

  1. Run IIS (exec 'inetmgr')
  2. Select your application (probably 'Server\Sites\Default web site\Your application name' from the tree on the left panel)
  3. Open your application settings (click 'Basic Settings' from 'Actions' the right panel) and look at the Application Pool.

  4. Now choose the action that best fits your needs:

    • You can change the application pool for your application (button select in 'Application Edit' form, then choose 'ASP.NET v4-0 Classic'). This change will effect just this application
    • OR you can edit the application pool (probably Server\Application pools\DefaultAppPool rom the tree on the left) and set it to run under .NET Framevork v4.0 . Be careful: this change will effect every application under this Application Pool... is this what you want? maybe...
Share:
36,510
Bronx
Author by

Bronx

Cyril Gupta is a long-time software developer A science-fiction/science freak 100% confirmed nerd. Loves to code in .Net (C#/VB.Net). Works on Web/Winforms/WPF. Uses CSS/Javascript too Founder Teknikforce Ventures LLC Websites: nishamadhulika.com, astrobix.com, blogvani.com, More... Others to come. Personal blog: cyrilgupta.com

Updated on July 09, 2022

Comments

  • Bronx
    Bronx almost 2 years

    I am trying to deploy a .Net framework 4 website on IIS7 server. I have already changed the application-pool's target framework to .Net 4, but the app is still showing me the error:

    "The configuration section 'system.web.extensions' cannot be read because it is missing a section declaration"

    I am guessing that has something to do with the new feature of .Net4 that lets me have a compact Web config file. I think for some reason IIS7 is not happy with this.

    What can I do to deploy this app successfully or do I have to scale back to v3.5? I am sure there is a solution out there.

    Do you have any suggestions?

  • Sebastian Castaldi
    Sebastian Castaldi over 13 years
    just in case the <sectionGroup name="system.web.extensions> is located in the Machine.config, just copy and paste in your Web.config group section
  • Saravanan
    Saravanan over 11 years
    Registering the ASP.Net Version 4.0 helped me fix my issue.
  • Scott Willeke
    Scott Willeke over 11 years
    @Cyril thanks. Despite the other half dozen answers telling us to use a .NET 4 AppPool (I was) this solution is the only one that worked.