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. =)
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).
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
Two more bits of info that may or may not help.
- the only difference from the above sectionGroup and my machine sectionGroup is the version=3.5.0.0 here and version=4.0.0.0 in the machine.config. 1.
- The error in the event log is "Could not load all ISAPI filters for site..." Could there be an install of System.Web.Extensions that is not registered properly with .net 4?
I'd love to test more on this, but unfortunately I only see this behavior in a production system and not a dev system.
来源:https://stackoverflow.com/questions/3209192/problem-with-system-web-extensions-config-group-when-upgrading-to-net-4-0