Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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. =)

like image 675
RPM1984 Avatar asked Jul 09 '10 01:07

RPM1984


2 Answers

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).

like image 52
RPM1984 Avatar answered Oct 01 '22 03:10

RPM1984


I ran into this issue recently and was able to resolve it after some troubleshooting. Hope what I did will help fix your issue too. 1. Make sure the App pool you are running for the site is using .NET 4 pipeline 2. Open your .csproj (or .vbproj if yours is a VB project) in Notepad and walkthrough the file and check if there are any hard coded references to v2.0 Framework files. In my case we had a "After Build" task that was using v2.0 compiler path which forced the app to still use 2.0 runtime. It was like below.

<Target Name=”AfterBuild” Condition=”’$(MvcBuildViews)’==’true’”>
<AspNetCompiler Condition=”’$(IsDesktopBuild)’ != ‘false’” VirtualPath=”temp” ToolPath=”$(WINDIR)\Microsoft.NET\Framework\v2.0.50727” PhysicalPath=”$(ProjectDir)\..\$(ProjectName)” />
<AspNetCompiler Condition=”’$(IsDesktopBuild)’ == ‘false’” VirtualPath=”temp” ToolPath=”$(WINDIR)\Microsoft.NET\Framework\v2.0.50727” PhysicalPath=”$(OutDir)\_PublishedWebsites\$(ProjectName)” />

Make sure to change them to v4.0 or even better make them confiurable. Hope that helps.

-Vamsi

like image 35
Vamsi Krishna Avatar answered Oct 01 '22 02:10

Vamsi Krishna