Problem with <system.web.extensions> config group when upgrading to .NET 4.0

RPM1984 picture RPM1984 · Jul 9, 2010 · Viewed 12.1k times · Source

So we've upgraded our site from 3.5 SP1 -> .NET 4.

When we ran the site, we got an Internal Server Error (500), stating the following configuration group could not be read:

<system.web.extensions>
        <scripting>
            <scriptResourceHandler enableCompression="true" enableCaching="true" />
            <webServices>
                <jsonSerialization maxJsonLength="999999" />
            </webServices>
        </scripting>
    </system.web.extensions>

We commented out this section and the website ran fine (but now we are getting problems with JSON - because of the above required property).

We've read threads on this issue, and most of them say "Your application pool is not running 4.0". And it is, so that's not the issue.

I've also read threads saying IIS is somehow reading an old machine.config file.

With .NET 4, as you know a lot of the sections of web.config have been moved to machine.config.

So we put this section back in the top of the web.config:

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

And the website now seems to work ok.

Still, im a little concerned if this is the correct solution.

Any ideas people? Is this the correct fix?

EDIT:

3 weeks and no answers...damn. =)

Answer

RPM1984 picture RPM1984 · Aug 3, 2010

As i've had no answers, and extensive googling resulted in no love either, i've decided to stick my original fix (adding the system.web.extensions section back into the web.config).